Results 1 to 5 of 5

Thread: Events of a control

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Events of a control

    Say I have 2 list boxes and It is a windows control library. I build it and then include it into my program.

    Anyway to get to the listbox events?

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    have you tried making them public inside the control library?
    eg:
    in the control library...
    VB Code:
    1. [COLOR=BLUE]Public[/COLOR] [COLOR=BLUE]Sub[/COLOR] ListBox1_MouseEnter([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Object[/COLOR], [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] ListBox1.MouseEnter
    2.     [COLOR=GREEN]'/// do stuff[/color]
    3. [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
    then in the form that you have the library added to...
    VB Code:
    1. [COLOR=BLUE]Dim[/COLOR] clsLib [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]New[/COLOR] ClassLibrary()
    2.  
    3. [COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button1_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button1.Click
    4.     clsLib.ListBox1.Items.Add("some stuff!")
    5. [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
    not sure if that helps you.
    ************************

    infact you could set the listbox's Modifiers to Public like this...
    Public WithEvents ListBox1 As System.Windows.Forms.ListBox
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by dynamic_sysop
    have you tried making them public inside the control library?infact you could set the listbox's Modifiers to Public like this...
    Public WithEvents ListBox1 As System.Windows.Forms.ListBox
    Yes I made the controls publics but I still cannot access them and Im not even sure how I would since they're not in the drop down boxes at the top like events usually are.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you mean that the the form using your control should access the listbox events and your control is made up of a usercontrol and 2 listboxes then the answer is that you'll need to give your usercontrol the same events and have the 2 child listboxes raise them. With just having the listboxes in the usercontrol then only the usercontrol can receive the events of the listboxes.

  5. #5

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Edneeis
    If you mean that the the form using your control should access the listbox events and your control is made up of a usercontrol and 2 listboxes then the answer is that you'll need to give your usercontrol the same events and have the 2 child listboxes raise them. With just having the listboxes in the usercontrol then only the usercontrol can receive the events of the listboxes.
    Example? I don't know *** you mean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width