473,881 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MDI and StatusStrip

I have an MDI app and would like to some text and place it in a
ToolStripStatus Label. How can I accomplish this?
Nov 17 '05 #1
3 7571
You add the text to the .Text property of the ToolStripStatus Label. You can
also set its tooltip by setting the .ToolTip property.

To get to a label you have already placed in your ToolStrip, use something
similar to the following code:

toolStrip.Items["labelName"].Text = "My Label Text";

The ToolStrip.Items property has an overload on both name and the index.
(You must have set the name property of your label to be able to access it
through the string indexer overload.)

Hope this helps...

Frisky

"wschlichtm an" <ws**********@d iscussions.micr osoft.com> wrote in message
news:FF******** *************** ***********@mic rosoft.com...
I have an MDI app and would like to some text and place it in a
ToolStripStatus Label. How can I accomplish this?

Nov 17 '05 #2
Oops, I left out a vital piece of info. I am trying to set the textlabel,
which is in the parent container, from the child instance.

"Frisky" wrote:
You add the text to the .Text property of the ToolStripStatus Label. You can
also set its tooltip by setting the .ToolTip property.

To get to a label you have already placed in your ToolStrip, use something
similar to the following code:

toolStrip.Items["labelName"].Text = "My Label Text";

The ToolStrip.Items property has an overload on both name and the index.
(You must have set the name property of your label to be able to access it
through the string indexer overload.)

Hope this helps...

Frisky

"wschlichtm an" <ws**********@d iscussions.micr osoft.com> wrote in message
news:FF******** *************** ***********@mic rosoft.com...
I have an MDI app and would like to some text and place it in a
ToolStripStatus Label. How can I accomplish this?


Nov 17 '05 #3
Ahhhh....

Well this really has two parts.

First, "How do I get to data in one class from another?" (In this case, from
a child window to a parent.)

Basically, all you need to know here is the relationship. Because this is an
MDIChild window, the relationship is a little different than if this was a
control or another window. So, this is probably the disconnect.

Since this is a child window of an MDI window, the window is put in an
MDIClient container. This is the list of MDI child window for the MDI
window. So, the parents parent is the MDI window itself. From there, you can
look in the controls collection of that window for the ToolStrip, and in the
ToolStrip's items for the ToolStripStatus Label control.

In code this might look like:
((ToolStripLabe l)((ToolStrip) ((MainForm)
Parent.Parent). Controls["toolStrip1 "]).Items["myLabel"]).Text = "The new
text";

Note that to get this to work there is a lot of casting that has to be done.
That is because the Controls and Items collections only know they contain a
generic item. You must cast it to get the full attributes of your
specialized item. Of course, this might fail, because for whatever reason
your named item is not of the type you said it was, or because you misstyped
the name entirely. So, a safer way might be:
Mainform mainForm = Parent.Parent as MainForm;
if (mainForm != null) {
ToolStrip toolStrip = mainForm.Contro ls["toolStrip1 "] as ToolStrip;
if (toolStrip != null) {
ToolStripLabel label = toolStrip.Items["meToo"] as
ToolStripLabel;
if (label != null) {
label.Text = "The new text";
}
}
}

Ugly, hugh? Well that leads me into part two.

Part two is, "What is the correct way to do this?"

I am going to leave the mechanics of this as an excercise here. If you can't
get it, let me know. But, this is critical for good design. And its best
learned by doing.

Good design says that each class should manage its own internals. Also,
other classes should not know about the internals of another class.

While the controls exposed here are public, they are buired in the UI. If
you had two or three controls that you needed to get from the ToolStrip, you
could quickly see how you would be writing a lot of code. But what if you
made a method of the main MDI form which encapsulated the code above? You
could pass in the name of the tool bar item you want, and it would return
the generic control. You would still need to cast it to the
ToolBarStatusLa bel, but this is still way easier than the code above. And,
it would work for anything else you put in the ToolStrip.

Hope this helps...

Frisky

For the first part, the MDI parent window is accessible to the child via the
Parent property. The Parent is actually just a
"wschlichtm an" <ws**********@d iscussions.micr osoft.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
Oops, I left out a vital piece of info. I am trying to set the textlabel,
which is in the parent container, from the child instance.

"Frisky" wrote:
You add the text to the .Text property of the ToolStripStatus Label. You
can
also set its tooltip by setting the .ToolTip property.

To get to a label you have already placed in your ToolStrip, use
something
similar to the following code:

toolStrip.Items["labelName"].Text = "My Label Text";

The ToolStrip.Items property has an overload on both name and the index.
(You must have set the name property of your label to be able to access
it
through the string indexer overload.)

Hope this helps...

Frisky

"wschlichtm an" <ws**********@d iscussions.micr osoft.com> wrote in message
news:FF******** *************** ***********@mic rosoft.com...
>I have an MDI app and would like to some text and place it in a
> ToolStripStatus Label. How can I accomplish this?


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1382
by: Jim Hubbard | last post by:
When you add a StatusStrip to a WinForm and add a Progressbar to the StatusStrip, setting the Progressbar alignment to "Right" does not move the Progressbar to the right on the Statusbar. Is this a bug?
3
25462
by: windsurfing_stew | last post by:
Hi, Winforms has the new StatusStrip control that replaces StatusBar in 1.1. I've looked high and low but can't seem to find how to get separators (|) in my status bar, eg Info1 | Info2 | Info3 | Info4 where Infos 1 to 4 are StatusLabels.
2
4458
by: robertino | last post by:
Hi all, (VS 2005 Pro, XP) I'm trying to place a statusstrip control on a window such that it acts like a statusstrip (!). Every time I try this, no matter what I do, I find that when I maximise other containers on the form to fill its' available surface, then these other controls slip behind the statusstrip to fill ALL the form's surface as if the statusstrip didn't even exist!. Statustrip dock property is bottom, other controls all...
5
3093
by: Marc | last post by:
Hello, I have a vb.net form that I've added a StatusStrip at the bottom. On that StatusStrip I've added a DropDownButton on which I've added a Menu containing 4 sub Items
0
2032
by: Rich | last post by:
Hello, I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar object - which contains panels and I can see the properties of the statusbar in the properties window in vb2005. But in the tools list of vb2005 I do not see a statusbar selection. Instead I see a statusStrip, and even though the Items collection has a property to set the statusStrip labels to sunken, etched,... I can see these appearances when I...
0
1118
by: banduraj | last post by:
I'm trying to use the StatusStrip on a windows form and I would like it to look like the older version in .NET 1.1 with Sunken labels. When I set the labels to Sunken and the borders to all it looks off centered and ugly. Is there something I'm missing?
2
4535
by: jcvoon | last post by:
Hi: I'm using VS2005, I've create a winform with the following controls: Add a ToolStripContainer Set it to dock to the form (Fill) Click in the top section. Add a menu strip Add a tool strip. Add another tool strip.
1
21036
by: Carla Simeoni | last post by:
I added a StatusStrip "Sstrip1" to a Form "Form1". In the procedure private void Form1_Load(...) I added the following statement: Sstrip1.Text = "Text in my StatusStrip";
1
9266
by: S. Viswanathan | last post by:
Hi! When mouse over on menuitem, the corresponding menuitem text should display in StatusStrip control. How to do this? Simillarly for when mouse over on toolstrip item, the corresponding toolstrip button tag property need to be taken.
10
5872
by: hzgt9b | last post by:
Using VS2005 (.NET 2.0), VB.NET, I have a windows forms application. I have a StatusStrip containing a ToolStripStatusLabal and a ToolStripProgressBar. I want to force the status label to behave like it's docked to "Fill" inside the StatusStrip and force the progress bar to behave like it's docked to "Right" inside the StatusStrip. Unfortunately I do not see any way to accomplish this using just one StatusStrip control. Does anyone...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11096
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9552
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7108
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.