C# ComboBox Pulldown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am making a combobox, where I add items to the combobox as they are
required, as the user scrolls to the top or bottom of the list of items. It
is a sorted combobox. Scrolling down works fine, but when they scroll up, the
positioning gets confused. If the ComboBox contains record 60-79, and they
pressed Up on 60, I trap the keypress and add records 40-59. I set the
SelectedItem to 59, and the SelectedIndex to its index, and the textbox field
contains 59, but when they press up or down, the pulldown jumps to record 39
or 41, as if it was on record 40, not 59. Does this make sense to anyone?

Assuming not, I would just like to close the pulldown and open it again
under program control. Is there a ComboBox method that allows the program to
open and close the pulldown (e.g. when the pulldown is open, you see the list
of possible values, with a scroll bar line on one, based on the value in the
textbox. When the pulldown is closed, you just see the textbox with the arrow
to press to see the pulldown).

Thanks.
 
Hi Richard,

Thanks for your post.

I think there are some implementation details not very clear, can you show
some complete code snippet or a little sample project for us? Then we can
understand your scenario much better.

Currently, for you #1 question, because I still did not understand it well,
I can not give any good suggestion(I suggest you provide more information).
However for #2, we can P/invoke and send CB_SHOWDROPDOWN to combobox to
control its dropdownlist state, like this:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam,
IntPtr lParam);
private const int CB_SHOWDROPDOWN=0x014F;

void HideDropDownList()
{
SendMessage(this.comboBox1.Handle, CB_SHOWDROPDOWN, (IntPtr)0,
IntPtr.Zero);
}

void ShowDropDownList()
{
SendMessage(this.comboBox1.Handle, CB_SHOWDROPDOWN, (IntPtr)1,
IntPtr.Zero);
}
============================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks Jeffrey,

I will try the code that you have suggested. I suspected that the first item
was not clear, if your suggestion does not work I will make it up into a
simple example and post it. Thanks.

Richard.
 
Hi Richard,

Ok, if you need further help, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Richard,

Is your problem resolved? If you still have any concern, please feel free
to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top