|
BillWoodruff wrote: First, I believe that Child Forms should never be used, that they lead to awkward user-interfaces, and the old MDI-architecture
..I'd like to see a version of Visual Studio with an SDI-interface. MDI isn't dead, it's merely abused a lot. We'll say the same thing about that Ribbon on a few years
BillWoodruff wrote: I think you can get better responses to this scenario if you describe what the function of your proposed use of "Child Forms" are, in relation to their "Parent" Form.
Good point; when an apparant beginner talks about child-forms, I usually assume (I know, we should check, not assume) that they need to display a dialog, and that they forgot to specify the owner of the form (often confused with the parent).
+5 for giving a very elaborate answer that does not only benefit the TS.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way.
Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions.
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
int screenHeigth = Screen.PrimaryScreen.Bounds.Height;
this.Size = new Size(screenWidth, screenHeigth);
this.Invalidate();
this.Update();
InitializeComponent();
this.pnlSi.Size = new Size(screenWidth, screenHeigth);
this.pnlSi.Invalidate();
this.pnlSi.Update();
this.pnldjt.Size = new Size(screenWidth, screenHeigth);
this.pnldjt.Invalidate();
this.pnldjt.Update();
Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.
|
|
|
|
|
How is it not showing in the correct way? what is the actual issue. All I can see is that you are setting 2 panels and the form to the same size at runtime
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
InitializeComponent(); should be the first statement after the constructor. Do you know what happens in that function? A lot of values, among them positions and sizes, are set.
I'd rather use a this.WindowState = FormWindowState.Maximized; in the Form_Shown event. If you want to re-order the elements, you can additionally subscribe to a Resize event, and do that there.
|
|
|
|
|
I believe Bernard Hiller gave you the correct answer (I voted his answer #5, naturally): move the call to InitializeComponent() to before your Form and Panel adjustment code.
An edge-case hypothesis could be: the monitors have different aspect ratios, but I doubt that.
best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
|
|
|
|
|
Hi,
I need to create a windows forms application having collapsible panel with some controls like label and picture box inside the panel.How to do this?Please help me by providing a sample solution or steps.Thanks in advance.
|
|
|
|
|
ukraju wrote: Please help me by providing a sample solution or steps.
That's the wrong way of learning to develop; you start with a book or easy tutorials and work trough that - starting a project without knowing where to begin and asking for help on every step of the way will not be a "fun" way of learning, because of comments like mine
If you've been assigned this "problem" by a teacher, please introduce him/her to this thread.
Drop a Panel on your form. Notice that you can hide/show the panel using it's Visible property, or the Hide/Show methods. Also note that a Panel inherits from Control , and that it can notify you if the user enters or leaves the panel (see MSDN[^]).
Drop your other controls on the Panel , and implement the logic to show it when the mouse enters the control, hides it when it leaves the control.
Next, you'll notice that it will not unhide; that is because you cannot "enter" an invisible control. So, we'll introduce the Size property right away: if the mouse enters the control, make the Panel a 100 pixels wide, if it leaves the control, make it 25 pixels wide. First state is called "Normal", seconds state is called "Collapsed".
You can earn bonus-points by wrapping it all in a re-usable UserControl and writing an article (submit on this site of course) on the topic. Yes, we welcome articles that provide a sample solution and/or steps.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I think you got the best possible advice from Eddie Vluggen in his post above: you need to "ground" yourself in the fundamentals of what Forms, and "container controls," like the Panel Control, are:
And, the fact that true "container controls," at design-time in Visual Studio, allow you to drag-and-drop other Controls within them, at which point those dropped Controls have their Parent property set to the Container Control they were dropped into: you hide the Parent container control: everything within it is hidden.
The only thing I can add here is to suggest that, to me, a "collapsible" Panel, implies that some part of it will always be visible: the simplest way to achieve that is, as Eddie suggested, to manipulate the Size property of the Panel using the Enter and Leave events of the Panel. If you want to leave the Panel "fully open" some of the time, when the user moves the mouse outside the Panel: that requires a different solution.
There are other, more sophisticated techniques (but still rather simple to code), for when you need multiple Panels that open and collapse within an outer Panel, leaving only one open, as in the famous "Outlook Bar" interface.
edit ... Hint: use Panels set to Dock.Top within an outer Panel, and respond to Click events on the inner panels by iterating the ControlCollection of the outer Panel, and doing the right thing to hide and collapse the inner Panels.
good luck, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
modified 11-Aug-12 21:34pm.
|
|
|
|
|
Again, Eddy's advice rules. But of course you could also use a command button to control the panel size. That way it changes when you tell it to rather than based on where the mouse is.
I've only recently used the panel for the second time and on this occasion I am placing an image, label and command button on at run time rather than design time one per row, based on the number of rows on a particular database table.
Its well worth the effort.
Ger
|
|
|
|
|
Good point, Ger,
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
panel2.ScrollControlIntoView(panel2.Controls[0]); ... 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
best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
modified 13-Aug-12 9:25am.
|
|
|
|
|
hello,
I have to open web page with address bar, specified width, Height from window forms without using
WebBrowser control.
help is appriciated
|
|
|
|
|
Then how are you going to show the page??
Without the WebBrowser control you'll have to implement your own rendering engine. Good luck with that!
|
|
|
|
|
Dave Kreskowiak wrote: Good luck with that!
Wheres that dammed sarcasm smiley!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
vikaskardode wrote: without using
WebBrowser control
Enjoy
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
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.
thanks, Bill
The glyphs you are reading now: are place-holders signifying the total absence of a signature.
|
|
|
|
|
I don't see any harm in doing this even though WinForms is not as hot as new technology with .NET, but you never know when someone might have a need for it and an article would be useful for them.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
BillWoodruff wrote: WinForms is now no longer of that much interest to CP members
I get the impression there are still lots of CPians using this technology, and will be for a good few years to come. If you think the article(s) would be useful then give it a go.
|
|
|
|
|
BillWoodruff wrote: is it really worthwhile to write this up
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[^]
|
|
|
|
|
i want to display large content i.e data may be 50 to 60 mb for example bible in desktop application.how i can do that?
|
|
|
|
|
What format is the data in?
Where is you data stored?
How do you want to retrieve it?
The simple answer is:
Write a program to to retrieve the data and display it in an appropriate control.
And the answer is just as useless as the question!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: And the answer is just as useless as the question!
But gets a 5 for trying.
|
|
|
|
|
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,
Rajesh
|
|
|
|
|
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.
|
|
|
|
|
Hai,
When I am trying to bind datatable to a superlist control it is throwing an error "Failed to compare two values in an array". Can any one help me on this issue.
|
|
|
|
|
I already did, and you didn't take the effort to respond. Are you expecting a different answer today?
Bastard Programmer from Hell
|
|
|
|
|