Visual Studio C# form design

LabProARW

Well-known member
Joined
Nov 4, 2019
Messages
52
Programming Experience
1-3
I have this plan of having a tab control with 7 tabs. Each tab is basically doing a filter or separate query to get only a subset of data from the multi-table relational database. One tab I want all methods. One tab I want only the QC category methods. One tab I want only RandD methods... etc. Now on the right side of the form I want to show all of the details of each method record found. I thought all was well until I figured out that the detail section if you will on the right side of the form, specifically referenced only the result of only one of the tabs. Of course this would not work whenever I clicked on a different tab. What is my best approach to having this form operate as I am describing?

Thanks in advance.
 
Show your code. Your vague explanation isn't helping, but seeing your code will help us determine what it is you are trying to do. How are you executing the code belonging to tab 2 through 7 if tab 1 is active?
 
One thing to keep in mind is that the TabControl works such that controls are not created until the TabPage hosting them is displayed for the first time. It's done to make loading heavy forms with TabControls more efficient. This can cause unexpected results if you are assuming that all controls will have been created when the form is first displayed. You need to either force the controls on other pages to be created on load or else don't use them until the first time their page is displayed.
 
Since I am using Visual Studio and this is my first toe in the water of C# and OOP, I have been wondering if it would be easier to do like I did MS Access and write most of it in code. In VBA I could click on a tab in the tab control, and by code easily change the code of the RecordSource of the 'Method Details' to use the same RecordSource as the tab selected. Trying to use the Properties of Method Details controls with VS leaves me lost which direction to go next to achieve what is easy in VBA and ACCESS. When I click on another tab the method list is different based on the classification/category that the tab represents.

Method Database CS.JPG
 
Here's how I would do it. I would populate a single DataTable with all the data. I would then filter that DataTable once for each TabPage. I think that you can do that by binding the DataTable to multiple BindingSources and then setting the Filter of each BindingSource as required. If not, you can create a DataView for each TabPage and bind that to a BindingSource and set the Filter. You would then bind each BindingSource to a DataGridView.

You would then have another BindingSource that would be bound to all the individual controls in the Method Details group. That BindingSource would be bound to the BindingSource that corresponds to the current TabPage. As you select a different TabPage, you bind the corresponding BindingSource to the single BindingSource on the right.
 
Back
Top Bottom