Update bound datagrid

J

Jorge

Hi

I have a bound datagrid to a dataset. I want to update
the underlaying sql table when the user finishes editing
the value.
I want to build a custom update sql statement using the
headerText and the Item values of the currentcell.
I've check the DataGrid1_CurrentCellChange but it doesn't
work the way i want its raised when i click on a cell. Is
there a sort of 'LostFocus' for datagrid cells so that i
can update the field immediately.

Kind Regards
Jorge
 
C

Cor

Hi Jorge,

Can you try if this fits your problem?

It shows only the first column

Cor

\\\
Private WithEvents dtbCol1 As DataGridTextBox
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Database.GetDataset(ds)
Dim ts As New DataGridTableStyle
ts.MappingName = ds.Tables(0).TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column = CType(ts.GridColumnStyles(0), DataGridTextBoxColumn)
dtbCol1 = DirectCast(column.TextBox, DataGridTextBox)
column.MappingName = ds.Tables(0).Columns(0).ColumnName
column.HeaderText = "Col1"
column.Width = 30
dv = New DataView(ds.Tables(0))
DataGrid1.DataSource = dv
End Sub
Private Sub dtbCol1_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dtbCol1.LostFocus
Dim I As String = "lostfocus"
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top