Results 1 to 2 of 2

Thread: Combobox and Tables.

  1. #1

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Combobox and Tables.

    I have a combobox with around 60 options in it. Each item in combobox needs to have a different data. To better explain it lets say i have combobox with 7 days in week.

    For each of those days i need to enter and save different data. When i choose one day from combobox in datagridview it should show me the data for it. It looks like this

    Name:  e6770dfd4ebd7dbb206b162b701b5293.jpg
Views: 236
Size:  13.8 KB

    Assuming i don't have other idea i want to go like this. I will create one .mdf database and store in it for each option from combobox the different Table. After all its done i would go with this code to load the table in datagridview
    Code:
      Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ComboBox1.SelectedItem = "Monday" Then
                DataGridView1.DataSource = Option1BindingSource
                'Me.TabelaKorisnikaTableAdapter.Fill(Me.BazaKorisnikaDataSet.tabelaKorisnika)
                Me.Option1TableAdapter.Fill(Me.UsersDatabaseDataSet.Option1)
            ElseIf ComboBox1.SelectedItem = "Tuesday" Then
                DataGridView1.DataSource = Option2BindingSource
                Me.Option2TableAdapter.Fill(Me.UsersDatabaseDataSet.Option2)
            ElseIf ComboBox1.SelectedItem = "Wednesday" Then
                DataGridView1.DataSource = Option3BindingSource
                Me.Option3TableAdapter.Fill(Me.UsersDatabaseDataSet.Option3)
            End If
        End Sub
    By adding 60 different if conditions and 60 different tables i think this will go super slow.

    Problem part ? How to add new rows with data to this datagridview? I thought with binding navigator but i don't know how.

    I know this is the worst possible way to resolve this problem so i wonder do you know any different way by not using ( 60 ) tables for each option ?

    Entire project .rar : OneDrive Link

    SS : Name:  d4a9ee8f7a7273ff6125c250cf4bf959.jpg
Views: 177
Size:  29.9 KB
    Last edited by t3cho; Mar 24th, 2015 at 01:21 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Combobox and Tables.

    What is the relationship between the data fro one option and that for another? Is there any? Is the data all in one table and there's a column that corresponds to the option or are they completely independent tables?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width