开发者

Why combobox refresh doesn't work?

I have a complex problem, could you please help me.

The problem:

I have a form with a TabControl. There are two TabPages in the first is a dataGridView and in the second are multiple comboboxes.

DataGridView is filled with data from Table1, on the other tab the first combobox datasource is set to TableCB1, the second combobox to TableCB2 etc.

Between TableCB1, TableCB2 ... are DataRelations like (TableCB1.ID->TableCB2.ParentID). I'm using databindings to bind current columns from table to controls.

When I open the form, first tabPage (dataGridView) is filled and works ok, but if I select the second TabPage (with comboboxes) then the combobox selected items are not correct sele开发者_如何学JAVActed!!! Only the first combobox is set correctly but all other have selected the first item in datasource until I change the bindingsource position or make dataset.rejectchanges().

But if make TabPage two to be shown on form load, then the combobox items are selected correctly!

I know it's a very specific problem but, hope somebody could help me to solve this problem.

I'm doing it on .NET3.5 and winforms.

Thanks.


The reply in this thread might be what you need:

DataBinding doesn't occur on Controls until the Controls are created. A TabPage creates child controls only after the TabPage has been made visible. To get DataBinding to occur, you'll need to force the child controls on the TabPage to be created and one way you can do that is by showing/hiding the TabPage (as you have discovered).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜