Hello to everyone, I have this code, that gives me an error on the marked
line. It is to make a reference to a submenuitem, to enable it thorgh it
name.
Error line:
For Each oSubitem As ToolStripMenuItem In oSubmenuItems
error: Message="No se puede convertir un objeto de tipo = Can´t convert
the type of object
'System.Windows.Forms.ToolStripSeparator' to type
'System.Windows.Forms.ToolStripMenuItem'."
If anyone knows how to solve this, it would be of great help
Thank you
Manek
Private Sub mkgv2_container_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.RecorrerEstructuraMenu(Me.men_principal,
mk_sqlre_2("sec_per_cat").ToString)
End Sub
Private Sub RecorrerEstructuraMenu(ByVal oMenu As MenuStrip, ByVal sOpcion
As String)
For Each oOpcionMenu As ToolStripMenuItem In oMenu.Items
If oOpcionMenu.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oOpcionMenu.DropDownItems, sOpcion)
End If
Next
End Sub
Private Sub RecorrerSubmenu(ByVal oSubmenuItems As ToolStripItemCollection,
ByVal sOpcion As String)
For Each oSubitem As ToolStripMenuItem In oSubmenuItems 'ERROR
LINE'||||||||||||||||||||||||||
If oSubitem.Name = sOpcion Then
oSubitem.Enabled = True
End If
If oSubitem.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oSubitem.DropDownItems, sOpcion)
End If
Next
End Sub 2 3539
The ToolStripItemCollection is a collection of 'ToolStripItem' not
'ToolStripMenuItems'. So maybe something like this (and I am not sure of
this part)...
For Each oSubitem As ToolStripItem In oSubmenuItems
if TypeOf oSubItem Is ToolStripMenuItem Then
...
The point being that a ToolStripSeperator is a ToolStripItem but not a
ToolStripMenuItem.
--
Terry
"Manekurt" wrote: Hello to everyone, I have this code, that gives me an error on the marked line. It is to make a reference to a submenuitem, to enable it thorgh it name. Error line:
For Each oSubitem As ToolStripMenuItem In oSubmenuItems
error: Message="No se puede convertir un objeto de tipo = Can´t convert the type of object 'System.Windows.Forms.ToolStripSeparator' to type 'System.Windows.Forms.ToolStripMenuItem'." If anyone knows how to solve this, it would be of great help
Thank you
Manek
Private Sub mkgv2_container_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.RecorrerEstructuraMenu(Me.men_principal, mk_sqlre_2("sec_per_cat").ToString)
End Sub Private Sub RecorrerEstructuraMenu(ByVal oMenu As MenuStrip, ByVal sOpcion As String)
For Each oOpcionMenu As ToolStripMenuItem In oMenu.Items If oOpcionMenu.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oOpcionMenu.DropDownItems, sOpcion)
End If
Next
End Sub
Private Sub RecorrerSubmenu(ByVal oSubmenuItems As ToolStripItemCollection, ByVal sOpcion As String)
For Each oSubitem As ToolStripMenuItem In oSubmenuItems 'ERROR LINE'||||||||||||||||||||||||||
If oSubitem.Name = sOpcion Then
oSubitem.Enabled = True
End If
If oSubitem.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oSubitem.DropDownItems, sOpcion)
End If
Next
End Sub
Thank you terry, it worked Perfectly!!!
"Terry" <Te***@nospam.nospam> escribió en el mensaje
news:00**********************************@microsof t.com... The ToolStripItemCollection is a collection of 'ToolStripItem' not 'ToolStripMenuItems'. So maybe something like this (and I am not sure of this part)...
For Each oSubitem As ToolStripItem In oSubmenuItems if TypeOf oSubItem Is ToolStripMenuItem Then ... The point being that a ToolStripSeperator is a ToolStripItem but not a ToolStripMenuItem. -- Terry
"Manekurt" wrote:
Hello to everyone, I have this code, that gives me an error on the marked line. It is to make a reference to a submenuitem, to enable it thorgh it name. Error line:
For Each oSubitem As ToolStripMenuItem In oSubmenuItems
error: Message="No se puede convertir un objeto de tipo = Can´t convert the type of object 'System.Windows.Forms.ToolStripSeparator' to type 'System.Windows.Forms.ToolStripMenuItem'." If anyone knows how to solve this, it would be of great help
Thank you
Manek
Private Sub mkgv2_container_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.RecorrerEstructuraMenu(Me.men_principal, mk_sqlre_2("sec_per_cat").ToString)
End Sub Private Sub RecorrerEstructuraMenu(ByVal oMenu As MenuStrip, ByVal sOpcion As String)
For Each oOpcionMenu As ToolStripMenuItem In oMenu.Items If oOpcionMenu.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oOpcionMenu.DropDownItems, sOpcion)
End If
Next
End Sub
Private Sub RecorrerSubmenu(ByVal oSubmenuItems As ToolStripItemCollection, ByVal sOpcion As String)
For Each oSubitem As ToolStripMenuItem In oSubmenuItems 'ERROR LINE'||||||||||||||||||||||||||
If oSubitem.Name = sOpcion Then
oSubitem.Enabled = True
End If
If oSubitem.DropDownItems.Count > 0 Then
Me.RecorrerSubmenu(oSubitem.DropDownItems, sOpcion)
End If
Next
End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Juan Irigoyen |
last post by:
I have created custom control that inherits from a control type toolstrip to
which I add several buttons to him, when using this control appears to me a
control toolstrip but without ningun button,...
|
by: Alex Clark |
last post by:
Hi all,
I'm using the ToolStrip in .NET 2.0, and I can't seem to find a way to
change the size of it. What I want is a toolbar the size of the IE toolbar,
preferably with text below images if...
|
by: trainersb |
last post by:
I am trying to use the ToolStrip control in Visual Studio 2005. I create a
C# Windows application & add a ToolStripContainer control to the form with
top, left, bottom & right panels visible. I...
|
by: iwdu15 |
last post by:
hi, im wondering if anyone else has had this problem. Whats going on, is
this: i have a tab control with 8 tab pages, each with about 10 controls.
Once and awhile, my ToolStrips will just randomly...
|
by: Anand Ganesh |
last post by:
Hello Everybody,
I am using the ToolStrip Control in .NET 2.0. I am also using a
ToolStripContainer Control.
I want to know how to retain the position of the ToolStrip Control in the...
|
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= |
last post by:
Hi
I'm trying to create a composite control to be used on a ToolStrip,
consisting of a ToolStripComboBox and a ToolStripButton. It's going to be a
control used to search for text in a grid...
|
by: Johnny Jörgensen |
last post by:
I'm doing a Visual Studio Add-In, and I had added an icon (let's say
"MyIcon.ico") to the project resources to use it as icon for the Toolwindow
tab.
Then I decided I didn't want to use that...
|
by: =?Utf-8?B?RWl0YW4=?= |
last post by:
Hello,
I have a WinForm application. The form has one Tab Control and one
ToolStrip. I would like to know what would be the best way to detect when
the user is "leaving" the Tab Control and...
|
by: Martijn Mulder |
last post by:
The ToolStrip on top of my form is to small. I want to increase its
height. Simply setting the Height-property doesn't change the height,
though. So I tried to place the ToolStrip in a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |