473,473 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Having one combobox updating another: what sequence of update is best?

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();

comboBox1.Items.Clear();

comboBox1.BeginUpdate();

foreach (FileInfo f in misfiles)
{
comboBox1.Items.Add(f.Name);
}
comboBox1.Update();
}

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 -
http://www.codeproject.com/csharp/cs...&select=359787)

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:)]

Question:
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:
http://seow.trianglesimsociety.org/corruptedimage.JPG

Thanks for any suggestions you may be able to provide.

MurdockSE

Jul 18 '06 #1
2 1604
This is an asp.net newsgroup. I think you need to post to another group.

mu*****@nc.rr.com wrote:
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();

comboBox1.Items.Clear();

comboBox1.BeginUpdate();

foreach (FileInfo f in misfiles)
{
comboBox1.Items.Add(f.Name);
}
comboBox1.Update();
}

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 -
http://www.codeproject.com/csharp/cs...&select=359787)

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:)]

Question:
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:
http://seow.trianglesimsociety.org/corruptedimage.JPG

Thanks for any suggestions you may be able to provide.

MurdockSE
Jul 18 '06 #2
Oops. Wrong group. I figure I will reply with my own answer to this.

"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.

MurdockSE"

Jul 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
20
by: MadCrazyNewbie | last post by:
Hey group, I keep getting the following error: "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at...
2
by: Bob | last post by:
I have an ArryList that I'm using as a datasource for a combobox. As an item is selected in the combobox and processed I'd like to remove it from the combobox. When I try I get an error stating...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
13
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window...
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
2
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello, I have a ComboBox that has a DataContext set on it. When a PropertyChanged event is fired (based on a static instance of some class), I'd like to update the DataContext on the combo, but...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.