Reputation: 4546
I have a problem with controls nested in a TabControl. I have a TabControl with n TabPages, with a DataGridView on each TabPage. Each DataGridView has a CheckBoxC column. I populate all datagridviews with different datasources (so each has different types of data). This is working ok!
I have added a ComboBox column so I can select all the rows on all DataGridViews. I do this programmatically (on a button click), and the counting of the selection is ok, except that the ticks are not added to checkBox cell of DataGridViews except on TabPage #1 (the one that I can see on startup).
If I click all the tabPages before I go and select all the rows in DataGridViews, the code works fine, and the ticks are added to all the rows (like I wanted).
But why this does not work without clicking all the tabPages? Is there any bug or something of TabControl?
Upvotes: 1
Views: 1767
Reputation: 5352
My workaround was to add this in the load event of the form.
this.tabcontrol1.BindingContext = this.BindingContext;
Upvotes: 1
Reputation: 992
I know this answer is correct for WPF, not positive about WinForms though. With WPF at least, it's a visually based interface, so the program does not load any of the objects/controls/etc on other tabs until they are clicked on. So it wouldn't be a bug, it's a part of the design.
I had a similar problem with trying to clear all textboxes on multiple tabs with a single button. I never did get it working, but I know there should be a way by using a combination of VisualTreeHelper
and a foreach
statement.
Again, this is based off of WPF and not WinForms, but hopefully it can point you in the right direction as to how to solve it.
Upvotes: 0