|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reference to a control error. Toolstripline. 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 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. -- Show quoteHide quoteTerry "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!!!
Show quoteHide quote "Terry" <Terry@nospam.nospam> escribió en el mensaje news:0081E6A6-C9D4-4D55-9C1D-E9105DC08DD5@microsoft.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 >> >> >> >> >> |
|||||||||||||||||||||||