Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27193

Getting an error while trying to define a DataGridView Column Type?

$
0
0
I have a DataGridView that is bound by a dataset upon Form_Load. I then call a routine that will define the Column Types for the Grid, however, I'm getting an error while trying to define a Column as a ComboBox. Here is my code below as well as a screenshot of the error. There error occurs on the red highlighted line.

Code:

    Private Sub FormatGridValues()
        Try
            With dgvTrans
                Dim txt1 As New DataGridViewTextBoxCell
                .Columns(0).CellTemplate = txt1
                .Columns(0).Visible = False

                Dim cmb2 As New DataGridViewComboBoxCell
                .Columns(1).CellTemplate = cmb2
                .Columns(1).Width = 95
                .Columns(1).HeaderText = "Type"

                Dim cal1 As New CalendarCell
                .Columns(2).CellTemplate = cal1
                .Columns(2).HeaderText = "Date"

                Dim cmb4 As New DataGridViewComboBoxCell
                .Columns(3).CellTemplate = cmb4
                .Columns(3).Width = 150
                .Columns(3).HeaderText = "Merchant"

                Dim txt5 As New DataGridViewTextBoxCell
                .Columns(4).CellTemplate = txt5
                .Columns(4).Width = 80
                .Columns(4).HeaderText = "Amount"

                Dim txt6 As New DataGridViewTextBoxCell
                .Columns(5).CellTemplate = txt6
                .Columns(5).Width = 250
                .Columns(5).HeaderText = "Notes"

                Dim btn As New DataGridViewButtonCell
                .Columns(6).CellTemplate = btn
                .Columns(6).Width = 95
                .Columns(6).HeaderText = "Update"
            End With

        Catch ex As Exception
            Dim strErr As String = "frmTransactions/FormatGridValues() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

Attached Images
 

Viewing all articles
Browse latest Browse all 27193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>