Using a For loop on a combobox values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manhaz
    New Member
    • Jun 2010
    • 1

    #1

    Using a For loop on a combobox values

    In this project I have 2 Combo boxes, 1 Button and 1 GridViewControl . Both the combo boxes have some variables and their associated values, as u can see in the code. Now when the button is pressed the GridViewControl is filled with the sum of all the variable in both the combo boxes and result should be displayed in GridViewControl (I have pasted the result on the user interface). If u look at the picture attached u can understand what I wanted this application to do. On top of each column I want to see combo boxes similar to the one I have on the form. I want to use For Loop, easy for me to understand.

    I need the code for the click button to generate this sample result (pasted on the picture).

    Public Class Form1

    Dim Prod1Dictionary As New Dictionary(Of String, Integer)
    Dim Prod2Dictionary As New Dictionary(Of String, Integer)

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    ComboBox1.Items .Add("Apple")
    ComboBox1.Items .Add("Blackberr y")
    ComboBox1.Items .Add("Cherry")
    ComboBox1.Items .Add("Select")
    ComboBox1.Text = "Select"

    ComboBox2.Items .Add("Grapes")
    ComboBox2.Items .Add("Grapefrui t")
    ComboBox2.Items .Add("Guava")
    ComboBox2.Items .Add("Select")
    ComboBox2.Text = "Select"

    Prod1Dictionary .Add("Select", 0)
    Prod1Dictionary .Add("Apple", 2)
    Prod1Dictionary .Add("Blackberr y", 3)
    Prod1Dictionary .Add("Cherry", 4)

    Prod2Dictionary .Add("Select", 0)
    Prod2Dictionary .Add("Grapes", 5)
    Prod2Dictionary .Add("Grapefrui t", 6)
    Prod2Dictionary .Add("Guava", 7)

    End Sub
    End Class
    https://<a href="http://s900.photobu...GridView"></a>
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    I don't really follow what you want the code to do.

    Rather than showing the intended end result, can you please try to set down, step by step, exactly what you want to happen? That's largely what programming is. Once you've worked out in detail what to do, translating in into VB (or another programming language) is usually a relatively simple task.

    Comment

    Working...