 |
 | Thanks  pintamono | 8:02 29 Dec '08 |
|
|
 |
|
 |
the simplest way to access the status bar of the mdi parent window is to make that status bar as static variable in the mdi parent, like this.
public static System.Windows.Forms.ToolStripStatusLabel statusbar;
then from any child window u can access that status bar just like this
mdiparent.statusbar.text = "Saved Successfully !";
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Yes - I believe that would work, but not perhaps as you expected.
As I steer away from the use of static as much as possible my recollection may be faulty, but I believe the use of static can have side effects that may cause some issues:
1. Static creates a class (rather than object) variable 2. Variable cannot have indexers (so no "this") 3. a static constructor for the class may be generated which cannot be overridden, cannot accept argument variables, and cannot reference object(instance) variables.
If those conditions don't bother your code fine, but otherwise it could cause some additional coding and/or debug pain.
All that said, it's certainly a more concide form.
Nothing is impossible, we just don't know the way of it yet.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
dear limey, i already have tested this approach in my code, and it is working perfectly.
Regarding ur points
1-when a child opens up under mdi, an instance of mdi already exists, so u just need to access the static variable of that instance, no need to create an object.
2-yes that is true that we have to remove all the "this" indexers for that variable, but what is the harm in doing this ?
3-there is no need of anyother change. all work fine.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,i m using vs 2005 & working in windows application of vb.net. the scenario is I m using MDIForm. From parent forms, i open a child form. on page load data is filled in datagridview named empgrid. I m trying to set mdiparent of a relevant form as nothing. i m using the code
If EmpGrid.IsCurrentRowDirty Then If IsDBNull(CType(sender, DataGridView).Rows(e.RowIndex).Cells(0).Value) Then Me.MdiParent = Nothing MessageBox.Show("Please inset the value") e.Cancel = True End If End If But it gives me the exception "Operation did not succeed because the program cannot commit or quit a cell value change"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
1 of my colleage has just find the solution. Basically the problem was that system got hault when i deleted the whole text from mentadaory cell. After removing the text, I press save button. System displays the message "Please insert the value" while row validating. This scenario occurs when v r using form as MDI but working fine with normal forms. So that's y i was asking how to set parent as null. Now v come to solution. On mdiparent form, there is a default property AutoValidate which is set to EnablePreventFocusChange. Change it 2 EnableAllowFocusChange. Everything will b fine. Who says nothing is impossible? I've been doing nothing for years.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Assuming that each child has a dedicated panel, then just assign the relevant panel reference
. . . newMDIChild1.pfrm_sp1 = statusBarPanel1; . . . newMDIChild2.pfrm_sp1 = statusBarPanel2; . . .
On the other hand, if each child adds a panel when created, add the panel to the parent and assign the new reference. Be careful of how many of these you end up with and, of course, adding a panel dynamically like this needs additional management of the panel collection. something like this ...
StatusBarPanel panel2 = new StatusBarPanel(); panel2.width = .. panel2.MinWidth = .. statusBar1.Panels.Add(panel2);
Form2 newMDIChild = new Form2(); newMDIChild.MdiParent = this; newMDIChild.pfrm_sp1 = statusBar1.panels(statusBar1.panels.indexOf(panel2)); newMDIChild.Show(); . . .
(see http://msdn2.microsoft.com/en-us/library/system.windows.forms.statusbar.statusbarpanelcollection(vs.80).aspx for help in working with the statusbarpanels collection)
Personally, I would try to design the application to support the first method (fixed number of panels) and assign/deassign them to the children as necessary, changing the background color when the child is active, and have a maximum number of children (say 4).
If this isn't possible, or you absolutely need LOTS of children, then I would minimize the width of all but the panel for the active child, and use icons or color to indicate if a message is posted to an inactive panel. Hovering on such a panel would show a tooltip with the panel textual content (I haven't tried this tooltip idea and have not the time to - if you try this let me know if it works as expected).
BTW, I haven't had an opportunity to try this technique with the new StatusStrip - maybe someday I'll have time to redo the article to include Net 2.0 controls.
Nothing is impossible, we just don't know the way of it yet.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Wow, I've been looking on Google for a way of doing this for hours(!!)
I can't believe it's so simple. *takes hat off*
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for the thanks.
I wish that MS (and others) would give tutorials for this kind of thing, rather than showing off how cleverly they can use the new foobar/whotzit/etc control.
Nothing is impossible, we just don't know the way of it yet.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hi, thanks a lot! I was trying to set some attributes of a MenuItem on the ParentForm from the ChildForm, and i couldn't even find a similar topic, so i'm really happy You have wrote this one. It is easy to understand and it works! This is really a very easy way of accessing MdiParent from MdiChild Once again, Thank You. Have a nice day!
marek. marek.pastorek@gmail.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |