|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OnRenderMenuItemBackground questionI'm trying the following but can't determine in the sub if e points to a
item that is checked. I did a quick watch and looked and looked but can not find anything that I can use to determine if it is checked. Am I missing something? Is it there? Protected Overrides Sub OnRenderMenuItemBackground(ByVal e As ToolStripItemRenderEventArgs) If e.Item.Tag Is Nothing Then Exit Sub MyBase.OnRenderMenuItemBackground(e) .... academic wrote:
Show quoteHide quote > I'm trying the following but can't determine in the sub if e points to a e.Item is declared as a ToolStripItem, which is a base class for *all*> item that is checked. I did a quick watch and looked and looked but can not > find anything that I can use to determine if it is checked. > > Am I missing something? Is it there? > > Protected Overrides Sub OnRenderMenuItemBackground(ByVal e As > ToolStripItemRenderEventArgs) > > If e.Item.Tag Is Nothing Then Exit Sub > > MyBase.OnRenderMenuItemBackground(e) > > ... the various bits and pieces that can appear on a ToolStrip. Not all of these can be 'checked', so ToolStripItem doesn't have such a property. BUT ToolStripMenuItem (which I suspect is what you are interested in) can be 'checked' and does have a Checked property. And ToolStripMenuItem *derives* from ToolStripItem, so the e.Item we are passed might actually *be* a ToolStripMenuItem. So we check (hoho): Protected Overrides Sub OnRenderMenuItemBackground(_ ByVal e As ToolStripItemRenderEventArgs) If e.Item.Tag Is Nothing Then Exit Sub MyBase.OnRenderMenuItemBackground(e) ' new stuff If TypeOf e.Item Is ToolStripMenuItem Then Dim menuitem As ToolStripMenuItem = DirectCast(e.Item, ToolStripMenuItem) ' now do stuff that depends on menuitem.Checked End If -- Larry Lard Replies to group please perfect
Thanks a lot Show quoteHide quote "Larry Lard" <larryl***@hotmail.com> wrote in message news:1141136564.160694.171990@i40g2000cwc.googlegroups.com... > > academic wrote: >> I'm trying the following but can't determine in the sub if e points to a >> item that is checked. I did a quick watch and looked and looked but can >> not >> find anything that I can use to determine if it is checked. >> >> Am I missing something? Is it there? >> >> Protected Overrides Sub OnRenderMenuItemBackground(ByVal e As >> ToolStripItemRenderEventArgs) >> >> If e.Item.Tag Is Nothing Then Exit Sub >> >> MyBase.OnRenderMenuItemBackground(e) >> >> ... > > e.Item is declared as a ToolStripItem, which is a base class for *all* > the various bits and pieces that can appear on a ToolStrip. Not all of > these can be 'checked', so ToolStripItem doesn't have such a property. > BUT ToolStripMenuItem (which I suspect is what you are interested in) > can be 'checked' and does have a Checked property. And > ToolStripMenuItem *derives* from ToolStripItem, so the e.Item we are > passed might actually *be* a ToolStripMenuItem. So we check (hoho): > > Protected Overrides Sub OnRenderMenuItemBackground(_ > ByVal e As ToolStripItemRenderEventArgs) > > If e.Item.Tag Is Nothing Then Exit Sub > > MyBase.OnRenderMenuItemBackground(e) > > ' new stuff > If TypeOf e.Item Is ToolStripMenuItem Then > Dim menuitem As ToolStripMenuItem = DirectCast(e.Item, > ToolStripMenuItem) > > ' now do stuff that depends on menuitem.Checked > End If > > -- > Larry Lard > Replies to group please >
View Source from WebBrowser (2005)
Help authoring tool for Windows app? Menory compaction Please help with an 'impossible' error! datagrid and vertical gridline color IIF in vb.net acts weird.. or is it me Using the && operator in generated JavaScript Web service - business objects don't show up FTP with SSH Eventhandler |
|||||||||||||||||||||||