473,799 Members | 2,885 Online
Bytes | Software Development & Data Engineering Community
+ 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_Selec tedIndexChanged (object sender, EventArgs e)
{
IniFile INI = new IniFile(@"c:\\d ata\TM.ini");

string MisFileDir = INI.IniReadValu e("Main", "MisFileDir ");

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

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

FileInfo[] misfiles = dir.GetFiles();

comboBox1.Items .Clear();

comboBox1.Begin Update();

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

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 1621
This is an asp.net newsgroup. I think you need to post to another group.

mu*****@nc.rr.c om 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_Selec tedIndexChanged (object sender, EventArgs e)
{
IniFile INI = new IniFile(@"c:\\d ata\TM.ini");

string MisFileDir = INI.IniReadValu e("Main", "MisFileDir ");

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

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

FileInfo[] misfiles = dir.GetFiles();

comboBox1.Items .Clear();

comboBox1.Begin Update();

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

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
12115
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 combobox. What is the solution? Thank you in advance.
20
2034
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 position 1." on the following line of code:
2
1899
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 that the arraylist is being used as a datasource and can't be updated. I can't remove it as the datasource for the combobox so I can update it and reassign it back as the datasource. Anyone got a workaround?
2
8674
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 list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
13
7458
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 will open.My problem is the pop-up window and the parent window has same combobox.if i add data through html form in pop-up window(Ex2.jsp) it enters the combobox...but the data in the combobox of parent window(Ex1.jsp) is entering only when i refresh...
10
2245
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 an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) { do{ echo "<tr><td text align='right'>";
2
3584
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 uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
2
9797
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 it seems that I need to set it to null first: Combo1.DataContext = null; Combo1.DataContext = dc;
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10219
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
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 we have to send another system
3
2937
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.