I want to add new row to gridcontrol at every button click. I tried many ways but no success. I am sending my code below.
private void B_Click(object sender, EventArgs e)
{
Button bt = (Button)sender;
Code
int productId = (int)bt.Tag; AddProductDataContext db = new AddProductDataContext();Code
decimal Quantity;Code
decimal.TryParse(txtCalculator.Text, out Quantity);Code
gridControl1.DataSource = from inv in db.Inventories where inv.RecId == productIdCode
select new {Code
inventoryName = inv.InventoryName,Code
Quantity, Total = Quantity * inv.InventoryPrice };Code
gridView1.AddNewRow();Code
gridView1.UpdateCurrentRow();}
Is there anyone to help me out there for the above? Thanks in advance for your precious replies.
Amit Kumar SinghRank #562 · 4.3K reputationPosted May 12, 2016, 8:08 AM EDT
You need to define the
DataTableat form level. Then in button click you can do:For defining table at form level: