473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Need some help with vb StatusStrip Control

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

What I am trying to do is cycle through the Menu's subitems one by one and
uncheck or check the items instead of setting them all individually.

So, here's what I want to avoid:

Private Sub SubToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles SubToolStripMenuItem1.Click

SubToolStripMenuItem.Checked = False
SubToolStripMenuItem1.Checked = False
SubToolStripMenuItem2.Checked = False
SubToolStripMenuItem3.Checked = True

End Sub

My DropDownButton is called: ToolStripDropDownButton1

My Menu that contains the 4 sub items is called: MyToolStripMenuItem

My sub items are: SubToolStripMenuItem, SubToolStripMenuItem1,
SubToolStripMenuItem2, SubToolStripMenuItem3

I've googled groups until my eyes have bled and I can't find an answer. I'd
like to use something like this:

Dim MI as MenuItem

For each MI in MyMenu.MenuItems
MI.Checked = false
Next
CType(sender, MenuItem).Checked = true

The problem is that I can't find a way to attach to the menu and get a hold
of each menu items .checked property.

Any ideas or pointers would be very helpful. I am trying to move from VB6
to .net and am having some headaches along the way.

Thanks,

Marc


Mar 11 '06 #1
5 3059

"Marc" <ma**@home.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
What I am trying to do is cycle through the Menu's subitems one by one and
uncheck or check the items instead of setting them all individually.


I was watching some of "Fahrenheit 451" on TV today. "Burn all the books,
they only make you unhappy". Hmmm, makes you think.

Here is some lousy code:

Dim thing
For Each thing In ToolStripDropDownButton1.DropDownItems
thing.checked = False
Next

Mar 12 '06 #2
Hey,

Thank you for the code, I tried it and found out it is only affecting the
DropDownButton menu but not the Sub ToolStripMenuItems. Let me see if I can
ASCII art what's happening here:

DropDownButton1
|
-TestToolStripMenuItem (Code below checks this menu when I set
thing.checked = true)
|
-- Test1ToolStripMenuItem
-- Test2ToolStripMenuItem
-- Test3ToolStripMenuItem
-- Test4ToolStripMenuItem
|
-TestTwoToolStripMenuItem (Code below checks this menu when I set
thing.checked = true)

So, here I have two main menus off of DropDownButton1. One menu called
"Test", the other called "Test two". The menu "Test" has sub items inside
it labeled "Test1", "Test2", "Test3" and "Test4". These Menu Items are the
ones I'm trying to check and uncheck. Your code below works perfectly to
check or uncheck the two "Top Level" menus on the button but not the
subitems.

The problem is trying to get to the subitme(s).checked property - I'm at a
loss here. and that's why in each subitems clicked event I've had to
hard-code this mess:

Private Sub Test1ToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles Test1ToolStripMenuItem.Click

Test1ToolStripMenuItem.Checked = True
Test2ToolStripMenuItem.Checked = False
Test3ToolStripMenuItem.Checked = False
Test4ToolStripMenuItem.Checked = False

End Sub

"Homer J Simpson" <no****@nowhere.com> wrote in message
news:5rJQf.22616$vC4.10903@clgrps12...

"Marc" <ma**@home.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
What I am trying to do is cycle through the Menu's subitems one by one
and uncheck or check the items instead of setting them all individually.


I was watching some of "Fahrenheit 451" on TV today. "Burn all the books,
they only make you unhappy". Hmmm, makes you think.

Here is some lousy code:

Dim thing
For Each thing In ToolStripDropDownButton1.DropDownItems
thing.checked = False
Next

Mar 12 '06 #3

"Marc" <ma**@home.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Thank you for the code, I tried it and found out it is only affecting the
DropDownButton menu but not the Sub ToolStripMenuItems. Let me see if I
can ASCII art what's happening here:


You will probably need to figure out which collection these items are in and
then access it via that collection and its members. That seems to be the way
things work now.

Mar 12 '06 #4

"Marc" <ma**@home.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Thank you for the code, I tried it and found out it is only affecting the
DropDownButton menu but not the Sub ToolStripMenuItems. Let me see if I
can ASCII art what's happening here:


http://samples.gotdotnet.com/quickstart/ might be worth a browse too.

Mar 12 '06 #5
On Sat, 11 Mar 2006 12:39:13 -0800, "Marc" <ma**@home.com> wrote:
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

What I am trying to do is cycle through the Menu's subitems one by one and
uncheck or check the items instead of setting them all individually.

So, here's what I want to avoid:

Private Sub SubToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles SubToolStripMenuItem1.Click

SubToolStripMenuItem.Checked = False
SubToolStripMenuItem1.Checked = False
SubToolStripMenuItem2.Checked = False
SubToolStripMenuItem3.Checked = True

End Sub

My DropDownButton is called: ToolStripDropDownButton1

My Menu that contains the 4 sub items is called: MyToolStripMenuItem

My sub items are: SubToolStripMenuItem, SubToolStripMenuItem1,
SubToolStripMenuItem2, SubToolStripMenuItem3

I've googled groups until my eyes have bled and I can't find an answer. I'd
like to use something like this:

Dim MI as MenuItem

For each MI in MyMenu.MenuItems
MI.Checked = false
Next
CType(sender, MenuItem).Checked = true

The problem is that I can't find a way to attach to the menu and get a hold
of each menu items .checked property.

Any ideas or pointers would be very helpful. I am trying to move from VB6
to .net and am having some headaches along the way.

Thanks,

Marc
I'm not all that sure what you are trying to accomplish, but if you
are simply trying to ensure that only the currently selected menu item
is checked, you can do this:
(Uses default names, VB2005)

In each MenuItem_Click Event add these two lines:
ClearChecks()
CType(sender, ToolStripMenuItem).Checked = True

Add this Sub:

Private Sub ClearChecks()
Dim MI As ToolStripMenuItem
For Each MI In Me.ToolStripDropDownButton1.DropDownItems
MI.Checked = False
Next
End Sub

Gene

Mar 12 '06 #6

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

Similar topics

0
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...
3
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 |...
2
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...
0
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...
6
by: Jon Slaughter | last post by:
When I used to program in windows(back in the days of win95/98) the help system was very good. You could find out all th details of just about anything with usually decent explinations of what does...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
I have a statusStrip on a form with some ToolStripStatusLabels - which function as Previous Record/Next Record, New Record buttons. And instead of text, I place an image on the...
1
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";
10
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...
1
by: Benj Nunez | last post by:
Hello everyone, I noticed that the statusStrip control seems to be always "raised". I tried looking for a property that would change this behavior. I tried the LayoutSyle property but it has no...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.