Indeed, a given UI of this type (sub-panels in a Panel) is may be designed to allow any number of sub-panels to be expanded, or collapsed,or "accordion style," allow only one sub-panel to be open at-a-time: that may mean you need to deal explicitly with visibility, assuming you have the Panel's 'AutoScroll property set to 'true, and there are sub-panels in the Panel's ControlCollection which are scrolled out of view.
I assume you add these controls to your sub-panels at run-time because: either you don't know the number of rows until run-time, or, the end-user may set a parameter that affects number of rows to be rendered into sub-panels on Load, or the user "on-the-fly" changes the number of rows they want rendered into sub-panels (via selection or query or whatever).
Personally, I'm a "true believer," in this situation, in creating a UserControl that can be multiply instantiated, that contains all sub-elements: such as the ones you described: image,label, command button, and then keeping a Collection of those back on the "ranch" (some "MainForm") in a form of a Generic Dictionary, which will vary depending on the scenario, but may be like: Dictionary<subPanel, bool>, where the Boolean might indicate if its "open," or "collapsed."
... edit ...
Assuming a scrollable outer container Panel: if the user does some selection activity ... outside the container Panel ... that will then determine that sub-panel#x needs to be visible, you may have to adjust the scroll-position in your code, if the targeted sub-panel is currently scrolled out-of-view: this is a reason why I like using a generic collection here: to get away from code like
... end edit ...
But, that's just another recipe from Mama's Kitchen, and I am not questioning the way you are doing things now: just extending your comment a bit.
"Each scenario may require a different UI solution that is optimal" is such a cliche, that I won't even mention it here
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
In back-and-forths with this poster on QA in this thread:[^]:
I am left with the idea about writing perhaps three articles, aimed at relative beginners with WinForms, showing how to use inheritance to create Forms that essentially duplicate an existing Form (where, for example, you want a set of standard identical controls with identical behaviors on every Form created).
Second, I would like to discuss the shortcomings of that approach when you, for example, wish one Form that inherits from a "master Form" to not have one of the inherited controls (which in the designer appear "locked" when: you create a new Form, add it to the Project, and then make it inherit from the "master Form.")
Third, I'd like to compare the strategy of switching between identically sized and positioned Forms to vary the user interface (which is what the OP of the QA post linked to above was after), vs. the simpler strategy of using Panels which are switched at run-time on one Form (but where said Panels may also use inheritance in the same way as described above with Forms).
My question is: given the possibility that WinForms is now no longer of that much interest to CP members compared to the latest "hot stuff:" is it really worthwhile to write this up, and include tricks like use of a static class to manage multiple Forms, or Panels, or modifying the Program.cs class to call an 'Initialize method in a static class, etc.
The glyphs you are reading now: are place-holders signifying the total absence of a signature.
Yes, it is. Not every shop uses WPF, a lot of them still build on the controls that they and their customers are familiar with. I'm still using WinForms as WPF isn't implemented in Linux. Yes, Gtk# might be an alternative, but that would introduce a learning-curve for anyone unfamiliar with Gtk#.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
Hai Lee Paul Alexander,
I am using your superlist control in my application. Can you please suggest me how to update,delete and add rows when it is binded through datatable.
However the binding is happening by creating a custom datatable and custom datarow. No i do not know how to update, delete and add rows in the control which will reflect in the database.
Thanks in Advance,
If you have a question about something you found in one of the articles, you should ask the question in the forum at the end of that article. It's very, very unlikely that Lee Paul Alexander will happen on the question in a none related forum, whereas he gets an email if you ask on that article.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
Below is the code that is actually closing the whole application when clicked on Yes.
But,I want to close the current form and open the new form when the user clicks on X with red mark i.e. close on the form.The code I wrote is :
<prelang="vb">Private Sub form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim response As MsgBoxResult
response = MsgBox("Do you want to close?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "confirm")
If response = MsgBoxResult.Yes Then
If response = MsgBoxResult.No Then
e.Cancel = True
I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error..
ERROR  [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1.
So plz tell me what would be the problem..
Last Visit: 31-Dec-99 19:00 Last Update: 1-Dec-22 4:41