Combo box Questions

  • Thread starter Thread starter Y. Sivaram
  • Start date Start date
Y

Y. Sivaram

Hi All,

Could you please give me some ideas regarding the questions below?

1) Is there any fast method to add items to the combo box with value member
and display member without setting data source. The problems in this method
is it makes the control flicker and very slow as well?

2) Currently to workaround I am padding the display member to 50 charcters
(its maxmimum length) and then adding the value member so that it will not
be shown in the drop down box. Then once the user selected the value, I take
a substring and get the value member. Is there any problems in this method
other than this padding and trimming hassle

3) Is there any way to set the width and height (number of items shown) in a
combox box

Best Regards,
Y. Sivaram
 
for Question #1

you can make a class SimpleItem with only two properties like ID ans
Description
So you will able to add it like this:

while(MyReader.Read())
{
this.MyCombo.Items.Add(new SimpleItem((int)MyReader.GetSqlInt32(0),
MyReader.GetSqlString(1).ToString()));
}

For get back your Data do:
int thisID =
((SimpleItem)this.MyCombo.Items[this.MyCombo.SelectedIndex]).Id;

____________________
Franky
(e-mail address removed)
 
For Question #3
What you are looking for is the MaxDropDownList property. It isn't
supported in the Compact Framework. I haven't seen it in any of the third
party controls either.

Paul Stork
(e-mail address removed)
 
Back
Top