Combobox with check items

T

tJ

I am searching for an example where a combobox is extended to contain
checkbox items. I've looked all day now, and so far the best links
are:

1) http://www.codeproject.com/useritem...100&forumid=421877&select=2100429&msg=2100429
and
2) http://www.codeproject.com/combobox/checkcombo.asp

The first CheckComboBox example is almost exactly right, except for
the fact that I'd like to keep the drop down list open while the user
checks items. At the moment it collapses after an item is selected :-
(

The second CheckCombo example is really old and written in C++ but the
way it functions is PERFECT.

Please could somebody enlighten me on how to get the DroppedDown
property for a combobox to stay true while checking items. Ideally,
the list should collapse only when the user clicks outside the control
or clicks the dropdown button.

Thanks in advance,
T
 
J

Jared

you could modify control and add this line to SLI event...

MyBase.DroppedDown = True




I had quick go at intercepting winMessage but it keeps drawing things in the
wrong place, here was my code...



Protected Overrides Sub wndProc(ByRef m As Message)

Dim t As Type = GetType(System.Windows.Forms.ListControlConvertEventArgs)
Dim c As New ListControlConvertEventArgs(Me, t, Me.Items)

If m.Msg = 273 And m.WParam = New IntPtr(66536) Then
Me.OnSelectionChangeCommitted(New EventArgs())
'Me.OnDropDownClosed(New EventArgs())
Me.OnFormat(c) 'New EventArgs())
Me.OnFormat(c) 'New EventArgs())
Me.OnSelectedValueChanged(New EventArgs())
Me.OnSelectedIndexChanged(New EventArgs())
Me.OnDrawItem(New DrawItemEventArgs(Graphics.FromHwnd(Me.Handle),
Me.Font, Me.Bounds, Me.SelectedIndex, DrawItemState.Default))
Exit Sub
End If


MyBase.WndProc(m)

End Sub
 
T

tJ

thanks Jared.

I've never worked with an SLI event? Could you provide an example?

I converted your override into the C# code below, but i'm unsure of
the commented line and the return statement. Are these equivalent?

I see what you mean, the check states update properly, but the list
isn't redrawn properly. Do you have any idea why?

Thanks in advance


protected override void WndProc(ref Message m)
{
//Dim t As Type =
GetType(System.Windows.Forms.ListControlConvertEventArgs)
Type t = new System.Windows.Forms.ListControlConvertEventArgs(null,
null, null).GetType();
ListControlConvertEventArgs c = new
ListControlConvertEventArgs(this, t, this.Items);

IntPtr ip = new IntPtr(66536);
if (m.Msg == 273 && m.WParam == ip)
{
this.OnSelectionChangeCommitted(new EventArgs());
this.OnFormat(c);
this.OnFormat(c);
this.OnSelectedValueChanged(new EventArgs());
this.OnSelectedIndexChanged(new EventArgs());
this.OnDrawItem(new
DrawItemEventArgs(Graphics.FromHwnd(this.Handle),
this.Font, this.Bounds, this.SelectedIndex,
DrawItemState.Default));
return;
}

base.WndProc(ref m);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top