Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datagridview combobox column problem

Posted on 2009-04-10
1
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 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