blah blah blah is here! blah blah » Close

up0down
link

Hi
Is there any way to drop a comboBox component on the form with n columns ?
I've been google it and i found same resources but very complicated!
Or is there the possibility when i pres a comboBox, to display a dataGridView near the component?
Thanks in advance!
David

last answered 2 years ago

1 answers

up0down
link

One thing you could do is to use a monospaced font (such as Courier New) and then create your own fixed length columns within the combobox. For example:
string item1 = String.Format("{0, 5}{1, 20}{2, 10}", 1, "John Doe", 21);
string item2 = String.Format("{0, 5}{1, 20}{2, 10}", 2, "Fred Bloggs", 42);
comboBox1.Items.Add(item1);
comboBox1.Items.Add(item2);
comboBox1.Font = new Font("Courier New", 10, FontStyle.Regular);
comboBox1.SelectedIndex = 0;

up0down
link

Thanks vulpes you are a gentleman!
It works!
David

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback