Regarding updating one comboBox from another: what order is best for clearing and updating the secon



I am having an issue with graphical corruption upon re-selecting a
combobox which upon 'selected index change' event should list file
names in that folder in a separate combobox. Here is the code:

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
IniFile INI = new IniFile(@"c:\\data\TM.ini");

string MisFileDir = INI.IniReadValue("Main", "MisFileDir");

//MessageBox.Show(MisFileDir + @"\" + this.comboBox2.Text +

DirectoryInfo dir = new DirectoryInfo(MisFileDir + @"\" +
this.comboBox2.Text + @"\");

FileInfo[] misfiles = dir.GetFiles();



foreach (FileInfo f in misfiles)

As you can see, I'm using an INI file class that utilizes a
kernel32.dll function to read from the INI. (see this article -

This part works perfectly well. And upon the first selection of
comboBox2 , comboBox1 usually updates fine with a list of files in the
given folder.

The problem comes primarily when I select a different index in
comboBox2, the comboBox1 imagery corrupts. I can still see the indexes,
but the text of that comboBox is invisible or garbled. [yes i should
have used the opposite numbers for their names! sorry for confusion:)]

My question is, am I updating the comboBox1 items in the appropriate
order? What is the best way to clear a combobox and re-add items to it?

Here is an image of the corruption:

Thanks for any suggestions you may be able to provide.





I was able to fix this drop down graphic corruption by removing the
BeginUpdate and Update calls. So, all I needed to do was Clear, then
Add items to the comboboxes. Thanks anyways.


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