adding toolstripmenuitem programatically and changing its properties

akalmand

Member
Joined
Jul 12, 2007
Messages
8
Programming Experience
Beginner
Hi there,

I am adding a tool strip manu item programatically using the following given code. what i want is that as the user adds another revision to the application, the previous revision gets unchecked and the new revision gets checked (bottom 2 lines of the code). I have no idea as to how to address the newly added item. I have tried all diff kinds of names but VB doesnot reconganizes any. Can you guys tell me how to do it. I am writing the code in a sub routine which uses frmProject as argument.

==========================================================
Dim mnuItemRevision As New System.Windows.Forms.ToolStripMenuItem

currentrevision = currentrevision + 1

mnuItemRevision.Name = "mnuItemRevisions" & currentrevision
mnuItemRevision.Text = "Revision " & currentrevision
frmProject.mnuRevisions.DropDownItems.Add(mnuItemRevision)

frmProject.mnuItemRevisions1.checked = False
**** frmProject.mnuItemRevisions2.checked = True
==========================================================

currentrevision = 1 at the beginning of the code.

**** - trouble area...

Please help. I am a begineer to any kind of programming, so detailed and easily explained answers will be helpful

I am using VB 2005

thanks

rohit
 
Is it the new mnuItemRevision you want to set Checked property for?
 
The idea is that any time a new revision can be added by the user. by doing so the old revision is unchecked and the new revision added will be checked.

In this case i am using mnuItemRevision to add a new revision and hence its checked property need to be set true...
 
It's no different than setting any other property, you seem to handle the Name and Text properties fine, so it's safe to carry on and set the Checked property also in the same manner.
 
works

thanks man,

it worked... i made a little change in the coding. the defined that check property where i defined name and text properties i.e before adding the item.

it works that way....

thanks again
 
Back
Top