Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have created an enhanced combo box (user control) which is placed on a form.

 

Any events that are common to both the usercontrol and combobox (in usercontrol) such as "_Validated" fire ok both in the usercontrol itself and the form which the user control sits.

 

However, the "_dropdown" event (which is only within the combobox itself and not by default a standard event in the user control) fires ok in the user control BUT DOESN'T fire in the Form, even though that form has a "_dropdown" event.

 

Any reason why ? I'm sure this is 101 stuff, but I can't find the issue.

Edited by Martin Brading
Posted
However' date=' the "_dropdown" event (which is only within the combobox itself and not by default a standard event in the user control) fires ok in the user control BUT DOESN'T fire in the Form, even though that form has a "_dropdown" event.[/quote']

Show some code. How do you have the event declared in the usercontrol? Is the event declared as public?

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

  • *Experts*
Posted

Did you remember to include MyBase.OnDropDown(e) in the user control's Protected Overrides Sub OnDropDown event?

 

as an example...

   'adjust dropdown width to largest item width
   Protected Overrides Sub OnDropDown(ByVal e As System.EventArgs)
       MyBase.OnDropDown(e)

       Dim i As Integer
       Dim itemSize As Drawing.SizeF

       If Me.Items.Count >= 1 Then
           Dim g As Graphics = Me.CreateGraphics
           For i = 0 To Me.Items.Count - 1
               itemSize = g.MeasureString(Me.Items.Item(i).ToString, Me.Font)
               If itemSize.Width > Me.DropDownWidth Then
                   Me.DropDownWidth = itemSize.Width
               End If
           Next
           g.Dispose()
       End If
   End Sub

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...