Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Regarding updating one comboBox from another: what order is best for clearing and updating the second box?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
murdock@nc.rr.com - 18 Jul 2006 15:30 GMT
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_ini.asp?df=100&forumid=3467&exp=...)

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
MurdockSE - 18 Jul 2006 17:50 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.