Help with adding dictionary lines to a DataGridView.

Hugh

New member
Joined
Oct 13, 2011
Messages
1
Programming Experience
Beginner
Hello, I'm a student at a college studying the BTEC Level 3 IT course and I've came across an issue in developing my program. It is due in tomorrow and I have no programming lessons between now and the due time, therefore cannot consult my programming teacher about the issue.

The issue itself is that, I have a form with combo boxes and text boxes, that store each field of information in a dictionary. The fields are RAM, Processor, Colour, HDD etc.

I'm made it so when I click an addition button on my form, it adds all of these into dictionaries, using the PC name as the key which they write out in a text box, and uses the numbers in the combo boxes such as the RAM as the values. But them, after that, I want to be able to clear my datagrid and add all of the dictionary files back into it via. a loop, not manually, but I don't exactly know how.

My program uses stream reader and writer on start up and close, loading the data into the dictionaries from text files, therefore I want the dictionaries to fill out the datagridview but I don't actually know how....

Here's some of the code:-

VB.NET:
  Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click 
        Dim DVDCheck As String


        If chkDVD.Checked = True Then


            DVDCheck = "Yes"


        Else


            DVDCheck = "No"


        End If


        Try


            If Not utilities.DicName.ContainsKey(txtCompName.Text.Trim) Then




                'Utilities is my class created to hold public shared subs, dictionaries and variables.
                'DicName, being the name dictionary, holds the Name as a value, with Name as a Key aswell.
                'DicRam uses the Name as a key once again, RAM as the value and so on and so fourth.


                utilities.DicName.Add(txtCompName.Text.Trim, txtCompName.Text.Trim)
                utilities.DicRam.Add(txtCompName.Text.Trim, cbRAM.Text.Trim)
                utilities.DicPro.Add(txtCompName.Text.Trim, cbProcessor.Text.Trim)
                utilities.DicCol.Add(txtCompName.Text.Trim, cbColour.Text.Trim)
                utilities.DicCool.Add(txtCompName.Text.Trim, cbCooling.Text.Trim)


            Else


                MessageBox.Show("Sorry, the chosen PC name has been taken - please reset the form.")


            End If


        Catch


            MessageBox.Show("Sorry, the PC addition failed.")


        End Try










        'Form Database is my DataGridView form, DGVdatabase is the DataGridView.


        FormDatabase.DGVdatabase.Rows.Clear()




        '#############################################
        'Here is where I want to add the code that loads the dictionaries into the DataGridView (DGVdatabase) but I don't know 
        'what code I need to write out, how to loop it so it adds every PC and how to differentiate between each PC's details.
        '#############################################




        'These resets my form for further PC additions.
        utilities.EnableEntry()


    End Sub


So yeah to summarize, I'm a learning programmer who as you can see isn't very clued up. If you could give the most basic solution possible without branching out into more complex things that would be great - thanks!
 
Back
Top