3

I have a DataGridview with two adjacent combobox columns. The first one (called StockCategory) is bound to a bindingsource on the StockCategory table in SQL Server 2012. The next column is the Stock combobox, bound to a bindingsource on the Stock table. The requirement is simple: when the user selects a Stock Category from the first combobox, the only stock items available in the Stock combobox should be those in the selected Stock Category.

Setting a filter to the Stock table, based on the Stock category selection, works fine:

this.StockBindingSource.Filter = "MaterialGroup = " + this.radGridView1.CurrentRow.Cells["MatGroup"].Value;

Except that in this case all comboboxes in the Stock column are then filtered to the filter value, and previous Stock values in other rows seem to disappear.

I know it's an old problem and I've been looking at all sorts of random solutions on the web, but nothing seems to work.

Any help will be appreciated (I'm using RadGridView but the solution is probably generic?)

svick
  • 236,525
  • 50
  • 385
  • 514
PeterJ
  • 364
  • 4
  • 17

1 Answers1

0

I have a general solution but it may not be as good to you as it was to me. you see, i simply prefer to use my own code when the .Net code seems to fail on me. so my suggestion is to leave the win-forms DataGridview filter, attach to the event of value change in the StockCategory combo box and filter your own values in the Stock combo box.

can you do it?

No Idea For Name
  • 11,411
  • 10
  • 42
  • 70
  • I haven't tried, but the problem seems to be that all the comboboxes in a particular column are tied to the same bindingsource, so a filter one one affects them all. Right now I am looking into the possibility of binding the embedded combobobox to a datatable which then gets filtered when the user enters the field. It is hard to believe,l though, that such an obvious and universal requirement is so difficult to do. – PeterJ Jun 26 '13 at 10:05
  • i have a long and bad experience in the field of disappointment from winforms functions, and particular in DB binding – No Idea For Name Jun 26 '13 at 10:24