1

I need to create a Windows Form with two DataGrids. On the right, there is a DataGrid which displays one selected table. Editing is disabled in this table. But selecting a row is possible. I use tow dropdowns to set up my select command for the database. On the left side I have placed a smaller DataGrid for editing items from the main table on the right.

A user should be able to click a row to select it. The content of the row should be displayed in the smaller DataGrid on the left. Like an Key-Value-Editor. The table has a column "Key" and a column "Value". The keys are the column titles of the DataGrid on the right. And the values are the content of the currently selected row.

gridControlEdit.DataBindings.Clear();
BindingSource bindingSource = gridControlTable.DataSource as BindingSource;
gridControlEdit.DataBindings.Add("DataSource", bindingSource, "aktiv", true, DataSourceUpdateMode.Never);

I am not sure why but bindingSource gets null even if my DataSource of the gridControlTable was set.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
MSandro
  • 11
  • 2

1 Answers1

0

The datatype DataSource is not the same type as BindingSource, so your "as" operator is returning null.

See Microsoft reference below https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/cscsdfbt(v=vs.110)

MrWuf
  • 1,478
  • 1
  • 14
  • 30