Windows Form DataGridView ComboBoxColumn does not open DropDown on Click

Last Reply 7 months ago By pandeyism

Posted 7 months ago

I have datagridview which has comboboxcolumn.But it won't dropping down. My code is:

    Private Sub returndetailsDGV_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles returndetailsDGV.CellContentClick
        If e.RowIndex >= 0 Then
            Dim index As Integer
            index = e.RowIndex
            Dim row As DataGridViewRow
            row = returndetailsDGV.Rows(index)
            Try
                returnBillDetailsDGV.DataSource = Nothing
                dbConnection()
                sql = "SELECT Product_ID_Barcode,Product_Name,Quantity,Unit_Price,Subtotal,Tax_Amount,ReturnType FROM purchasereturn_transaction_database WHERE Bill_ref_No='" & row.Cells(0).Value & "';"
                cmd = New MySqlCommand(sql, conn)
                dt = New DataTable
                da = New MySqlDataAdapter
                Dim bsource As New BindingSource
                da.SelectCommand = cmd
                da.Fill(dt)
                returnBillDetailsDGV.AutoGenerateColumns = False

                'Set Columns Count
                returnBillDetailsDGV.ColumnCount = 7

                'Add Columns
                returnBillDetailsDGV.Columns(0).Name = "Product_ID_Barcode"
                returnBillDetailsDGV.Columns(0).HeaderText = "Product ID"
                returnBillDetailsDGV.Columns(0).DataPropertyName = "Product_ID_Barcode"

                returnBillDetailsDGV.Columns(1).Name = "Product_Name"
                returnBillDetailsDGV.Columns(1).HeaderText = "Product"
                returnBillDetailsDGV.Columns(1).DataPropertyName = "Product_Name"

                returnBillDetailsDGV.Columns(2).Name = "Quantity"
                returnBillDetailsDGV.Columns(2).HeaderText = "Quantity"
                returnBillDetailsDGV.Columns(2).DataPropertyName = "Quantity"

                returnBillDetailsDGV.Columns(3).Name = "Unit_Price"
                returnBillDetailsDGV.Columns(3).HeaderText = "Unit Price"
                returnBillDetailsDGV.Columns(3).DataPropertyName = "Unit_Price"

                returnBillDetailsDGV.Columns(4).Name = "Subtotal"
                returnBillDetailsDGV.Columns(4).HeaderText = "SubTotal"
                returnBillDetailsDGV.Columns(4).DataPropertyName = "Subtotal"

                returnBillDetailsDGV.Columns(5).Name = "Tax_Amount"
                returnBillDetailsDGV.Columns(5).HeaderText = "Tax_Amount"
                returnBillDetailsDGV.Columns(5).DataPropertyName = "Tax_Amount"

                returnBillDetailsDGV.Columns(6).Name = "ReturnType"
                returnBillDetailsDGV.Columns(6).HeaderText = "ReturnType"
                returnBillDetailsDGV.Columns(6).DataPropertyName = "ReturnType"

                Dim Status As New DataGridViewComboBoxColumn
                Status.Name = "ReturnType"
                Status.Items.Add("Yes")
                Status.Items.Add("No")
                returnBillDetailsDGV.Columns.Insert(7, Status)
                bsource.DataSource = dt
                returnBillDetailsDGV.DataSource = dt


            Catch ex As MySqlException
                Dim path1 As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "Errorlogs")
                Dim path As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "Errorlogs\Error.txt")
                path = getfileName(path)
                If (Not System.IO.Directory.Exists(path1)) Then
                    System.IO.Directory.CreateDirectory(path1)
                    Using sw = New StreamWriter(path, False)
                        sw.Write(String.Format("Message:{0}{1}\n Date:{2}{1}------------------------------------------------------------------------", ex.Message, Environment.NewLine, DateTime.Now.ToString(), Environment.NewLine))
                    End Using
                    EncryptFile(path, path)
                    MessageBox.Show("Error is occured! Please get error file at : " + path)
                    Application.Exit()
                Else
                    Using sw = New StreamWriter(path, False)
                        sw.Write(String.Format("Message:{0}{1}\n Date:{2}{1}------------------------------------------------------------------------", ex.Message, Environment.NewLine, DateTime.Now.ToString(), Environment.NewLine))
                    End Using
                    EncryptFile(path, path)
                    MessageBox.Show("Error is occured! Please get error file at : " + path)
                    Application.Exit()
                End If
            Finally
                conn.Close()
                cmd.Dispose()
            End Try
        End If
    End Sub

 

 

This question does not have replies marked as Answer.