0

I have a list bound to a Datagrid via a Bindinglist, I need a full 2 way databinding

 MyBindingList = new BindingList<Item>(List<Item>);
 SmartGridItems.DataSource = _myBindingList;

I cannot find out now, how I can access the Item, if I know the row in the grid.

e.g. after editing I want to validate the item, but I can do that only if I get a reference to the Item that has been edited.

Or how can I retrieve the item in my list if I know the associated row in the grid.

Thank you very much for your help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
traveller
  • 189
  • 1
  • 2
  • 10

1 Answers1

0

You can try using the DataBoundItem of the DataGridViewRow:

var item = (Item) row.DataBoundItem;
King King
  • 61,710
  • 16
  • 105
  • 130
  • Thank you very much for your hint. Unfortunately the Row of the Grid I use does not have a propberty DataBoundItem (), but I just checked it. It seems the same property in my Grid is called Data, so thank you very much. Probably this is the answer. – traveller Oct 18 '13 at 16:21
  • @Wolfgang are you using a third-part `grid`? I thought you're using the standard `DataGridView`. – King King Oct 18 '13 at 16:22
  • @Wolfgang looks like you're using the obsolete control `DataGrid` in `winforms`, you should use a `DataGridView` instead, it's more functional and productive. Even using the standard `DataGridView` is not good (for its appearance) but at least it's the standard control. – King King Oct 18 '13 at 16:30
  • Actually I am using a third party grid, that also runs on Windows Embedded Compact 7 Resco Smartgrid, but I did not mention it, because I was greatful for any hint, and with your hint, it really think I solved my problem. Thank you. – traveller Oct 18 '13 at 16:32