Save changes to datagrid

  • Thread starter Thread starter George
  • Start date Start date
G

George

Hi,

I'm changing the value of a cell in a bound datagrid to the path to a
selected filename. However this change is only saved if I click in a
different row in the datagrid afterwards.

How can I force this change to be saved?

The code I'm using to change the value of a cell follows:

Dim myCell As DataGridCell
Me.OpenFileDialog1.Filter = "Microsoft Access (*.mdb) | *.mdb"
If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
myCell = Me.dgDatabases.CurrentCell
Me.dgDatabases(myCell) = Me.OpenFileDialog1.FileName
End If

This code works, but the change is only saved if I click a different row
afterwards.

Also, if I edit a cell manually, a pencil appears, but not when using
the above code.

Kind regards,

George
 
George,

This is the number 2 most asked question in this newsgroup. The answer is
simple the data is pushed down in the datasource when there is a line
change.

You can force that however as well with when the datasource by instance is
ds.Tables(0)
\\\
BindingContext(ds.Tables(0)).EndCurrentEdit()
///

I hope this helps,

Cor
 
Cor said:
You can force that however as well with when the datasource by instance is
ds.Tables(0)
\\\
BindingContext(ds.Tables(0)).EndCurrentEdit()
///

Hi Cor,

I don't know what my datasource is. I have data adapter called
daDatabases, and a dataset called dsODBC_INI. The datasource for the
datagrid is me.dsODBC_INI.databases, but me.dsODBC_INI.databases has no
method called "EndCurrentEdit()". Please help...

Thanks,

George
 
George,

Strange name however lets assume that it is the datasource than
\\\
BindingContext(dsODBC_INI.databases).EndCurrentEdit()
////

Cor
 
Back
Top