[C#] howto compare combobox-item with DataSet

This is a discussion on [C#] howto compare combobox-item with DataSet within the C# Programming forums, part of the General Programming Boards category; Hello Everybody! ik made a program in C# to save OV-numbers, i made this by using a DataSet and a ...

  1. #1
    The Programming Dutchman
    Join Date
    Jan 2008
    Posts
    55

    [C#] howto compare combobox-item with DataSet

    Hello Everybody!

    ik made a program in C# to save OV-numbers, i made this by using a DataSet and a XML file.
    in the DataSet there a two Columns one called OV-numbers and the other one is called Status.

    Things that i already can with this program:
    * add a new item to the Dataset and save in in the XML file.
    * Show all the items in a listbox.

    the next thing i would like to do with this program is: modify each single Status item in the column 1. each of this numbers is connected to a OV-number.

    each of the OV-numbers are added into the Combobox: cmbxOVnummer. the ranking in the listbox where i showed the items is the same like in the combobox. in the code i tried to search trough all the rows in the Data-table looking for the same item(OV-number in colomn 0)that is selected in the combo-box(OV-number)

    after that i checked the radio buttons of be checked of not. as you can see then i try to change the Status in that row who is picked out the foreach-loop. after that i try to save the modified items and write it in the XML file. and refresh the listbox too see the changes.

    But all this is not working and there dont show up any Errors of warnings when i run this program.

    So what is wrong about this? and how could i fix it?

    Code:
    private void btnVeranderStatus_Click(object sender, EventArgs e)
            {
                foreach (DataRow drStudents in dsStudenten.Tables["student"].Rows)
                {
    
                    if (cmbxOVnummer.SelectedValue == drStudents[0])
                    {
                        if (rbtnAanwezig.Checked)
                        {
                            drStudents[1] = "1";
                        }
                        else
                        {
                            drStudents[1] = "0";
                        }
                    }
                }
    
                dsStudenten.AcceptChanges();
    
                StreamWriter WriteChangestoXML = new StreamWriter("studenten.xml");
                dsStudenten.WriteXml(WriteChangestoXML);
                WriteChangestoXML.Close();
                lbxStudenten.Refresh();
    
    
            }

    who wants too see all the code

    go to http://www.keepmyfile.com/download/50d26a2325571

    and click download i upload a .txt file with the code.

    thank you for your support

    Jeltn.
    Last edited by Jelte; 08-26-2008 at 12:16 PM.

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    I have a hard time understanding what you're saying. However, I noticed that you made a rookie combobox mistake. I've made the same mistake before.

    When you used "cmbxOVnummer.SelectedValue", what you probably meant was "cmbxOVnummer.SelectedItem".

  3. #3
    The Programming Dutchman
    Join Date
    Jan 2008
    Posts
    55
    Thanks for your reply, maybe it was smart to say that i am dutch, so my english is not always that good like you english folks.

    thanks you very much it works now

    Please be honestly, but i am curious How bad is my english: 1 too bad. 2 just bad. 3 medium. 4 not very bad. 5 just a little bit bad :P
    Last edited by Jelte; 08-26-2008 at 03:42 PM.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    Your English isn't very bad at all.

    Really its probably more my fault - I don't put very much effort into trying to understand people's posts, so if the problem isn't phrased in a perfectly clear manner that I can understand, I probably won't "get it". Unfortunately, not everyone thinks like I do, so there are plenty of posts out there that I just don't bother trying to understand.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 12:52 PM
  2. Retail Outlet Managment System - the 4th
    By Presidentofusa in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 10:44 PM
  3. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 04:41 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  5. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 12:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21