Datagrid

  • Thread starter Thread starter sch
  • Start date Start date
S

sch

Hi
I am using a datagrid in VB.NET. When I am adding data
one of my cells should get data aitomatically from the
other cells like adding the price in 2nd and 3rd cells
should compute sum and put in the 4th cell.
Any help is greatly appreciated.
Thanks
 
Hi,

Add a calculated column to the dataset. Here is an example

Private Sub AddPrice()

Dim dc As DataColumn

dc = New DataColumn("Price")

dc.DataType = System.Type.GetType("System.Decimal")

dc.Expression = "Quantity * Each"

dsInvoicesData.Tables(0).Columns.Add(dc)

dc = Nothing

End Sub

Ken
 
Hi Ken,
Thanks for your code but when using your expression -
dc.Expression = "Quantity * Each"

I am repalcing quntity as follows
datatable1(datagrid1.currentrowindex)("Expression")

it is giving error as the currentrowindex is not yet saved
in the datagrid. My problem is I wanted to see the values
on the grid before the that new row is saved.

Thanks
Chs
 
Back
Top