Solved

Datagridview combobox column problem

Posted on 2009-04-10
1
206 Views
Last Modified: 2012-05-06
I have a grid that has a column of comboboxes.  I'm pulling from a database for three separate conditions and filling three datasets.  I want to bind these datasets to one particular column, but only every third cell.  In other words, row one should bind to ds1, row 2 to ds2, row 3 to ds3, row 4 to ds1, row 5 to ds2, etc.

I am doing this

        For rw As Integer = 0 To 23 Step 3
            Dim cell As New DataGridViewComboBoxCell
            cell.DataSource = dsslide1
            dgvNewJob.Rows(rw).Cells(1) = cell
         Next

        For rw As Integer = 1 To 23 Step 3
            Dim cell As New DataGridViewComboBoxCell
            cell.DataSource = dsslide1
            dgvNewJob.Rows(rw).Cells(1) = cell
         Next

I get errors and the box does not contain any data.

Any ideas what I am doing wrong?
0
Comment
Question by:ddepuemd
1 Comment
 

Accepted Solution

by:
ddepuemd earned 0 total points
ID: 24121865
I found the answer to load different values in comboboxes in the same column of a datagridview.
            'fill slide and type 1

            For rw As Integer = 0 To 23 Step 3

                Try

                    Dim cell As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dsslide1.Tables(0).Rows.Count - 1

                        cell.Items.Add(dsslide1.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(1) = cell
 

                    Dim cell1 As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dstype1.Tables(0).Rows.Count - 1

                        cell1.Items.Add(dstype1.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(7) = cell1

                Catch ex As Exception

                    errlog.WriteError("Error in filling slide1 and type1: " & ex.Message, "LoadNewJob")

                End Try

            Next
 

            'fill slide and type 2

            For rw As Integer = 1 To 23 Step 3

                Try

                    Dim cell As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dsslide2.Tables(0).Rows.Count - 1

                        cell.Items.Add(dsslide2.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(1) = cell
 

                    Dim cell1 As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dstype2.Tables(0).Rows.Count - 1

                        cell1.Items.Add(dstype2.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(7) = cell1

                Catch ex As Exception

                    errlog.WriteError("Error in filling slide2 and type2: " & ex.Message, "LoadNewJob")

                End Try

            Next
 

            'fill slide and type 3

            For rw As Integer = 2 To 23 Step 3

                Try

                    Dim cell As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dsslide3.Tables(0).Rows.Count - 1

                        cell.Items.Add(dsslide3.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(1) = cell
 

                    Dim cell1 As New DataGridViewComboBoxCell

                    For cnt As Integer = 0 To dstype3.Tables(0).Rows.Count - 1

                        cell1.Items.Add(dstype3.Tables(0).Rows(cnt).Item("description"))

                    Next

                    JobGrid.Rows(rw).Cells(7) = cell1

                Catch ex As Exception

                    errlog.WriteError("Error in filling slide3 and type3: " & ex.Message, "LoadNewJob")

                End Try

            Next

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now