Search Results

Search found 2 results on 1 pages for 'andyperfect'.

Page 1/1 | 1 

  • Getting the highest owner of a ToolStripDropDownItem

    - by andyperfect
    I'm currently working on a project in which at one point, the user may right click a button which brings up a contextMenuStrip. I am already able to find the owner accurately from that strip, and manipulate the button clicked as follows: Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem) Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip) Dim buttonPressed As DataButton = DirectCast(cms.SourceControl, DataButton) But now for the tricky part. Within this contextmenuStrip, I have a DropDown menu with multiple items in there. I would assume you would be able to work your way up the ladder doing casts like above in the manner of ToolStripDrowpDownItem > ToolStripDropDownMenu > ToolStripMenuItem > ContextMenuStrip Unfortunately, when I try to get the sourcecontrol from this menuStrip, it return Nothing. Any ideas on how I can get the button that was pressed from this toolStripMenuItem? My current code is as follows (in which the sourceControl is Nothing) Dim myItem As ToolStripDropDownItem = CType(sender, ToolStripDropDownItem) Dim dropDown As ToolStripDropDownMenu = CType(myItem.Owner, ToolStripDropDownMenu) Dim menuItem As ToolStripMenuItem = CType(dropDown.OwnerItem, ToolStripMenuItem) Dim cms As ContextMenuStrip = CType(menuItem.Owner, ContextMenuStrip) Dim buttonPressed As DataButton = DirectCast(cms.SourceControl, DataButton) Any ideas on how to go about doing what I did in that first method, but just working my way up from further down the ladder?

    Read the article

  • Serializing an extended form object

    - by andyperfect
    I've been reading up on this whole subject, but I never came across this specific problem. I already understand that the whole idea of serializing an entire form is a horrible idea and just doesn't work. But, I am encountering a bit of a different problem. I have a class that inherits the "button" form object, that I call DataButton. Now for my problem. I want to be able to serialize this class, but I don't need any of the information from the actual button class. Is there any way to bypass the fact that I can't set the button form object to Serializable() and notify VB that when serialization is to occur, it should simply skip over that information? Theoretically, if such a procedure were possible, I'd be able to do the entire serialization without a hitch. I came up with the idea earlier of removing the "inherits" feature from the class, and having simply a button within the class, but that makes my program really difficult to work with as I am constantly changing the location, size, backgroundImage, text, and whatnot. Thus, immediate updates would be much tougher to work with. Any help would be greatly appreciated.

    Read the article

1