hi I m using data grid view with check box in search page in vb.net windows form
it is showing two extra field which I did not add even i make it false in visible
but in run time it is showing
herewith I given the coding please check & help------
Private Sub frmUploadCustomerFiles_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Location = New Point(Me.MdiParent.ClientSize.Width / 2 - Me.Width / 2, Me.MdiParent.ClientSize.Height / 2 - Me.Height / 2)
dgvSearch.Columns.Add("MDS_RecNum", "Customer_ID")
Dim colToCheck As New DataGridViewCheckBoxColumn
dgvSearch.Columns.Add(colToCheck)
Dim view As New DataGridViewLinkColumn
dgvSearch.Columns.Add(view)
chk = New CheckBox
chk.Size = New Size(16, 16)
chk.BackColor = Color.DarkGreen
AddHandler (chk.CheckedChanged), AddressOf chk_CheckedChanged
chk.Location = New System.Drawing.Point(7, 10)
dgvSearch.Controls.Add(chk)
FillState()
End Sub
---------------------------------------------------------------------------------------------------------------
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Try
LocationSearchByIdOrAddress()
Catch ex As Exception
DisplayError(ex)
LogApplicationsErrors(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, Me.Name)
End Try
End Sub
----------------------------------------------------------------------------------------------------------------
Public Sub LocationSearchByIdOrAddress()
Try
If txtSearchKey.Text.Trim = "" And cboState.Text.Trim = "" And txtCity.Text.Trim = "" Then
MsgBox("Please enter atleast one data to search", MsgBoxStyle.Information, "Enter")
txtSearchKey.Select()
Exit Sub
End If
Dim sqlstr As New StringBuilder
Dim dsCusmas As New DataSet
dgvSearch.Visible = False
sqlstr.Append("ESP_SearchCustomerUpLoadFile ")
sqlstr.Append(PrepareString(txtCity.Text.Trim) & COMMA)
sqlstr.Append(PrepareString(cboState.Text.Trim) & COMMA)
sqlstr.Append(PrepareString(txtSearchKey.Text.Trim) & COMMA)
sqlstr.Append(PrepareString(1))
Application.DoEvents()
lblmessage.Text = "Searching please wait........"
Application.DoEvents()
dsCusmas = getSQLDataSet(sqlstr.ToString)
dgvSearch.DataSource = dsCusmas.Tables(1)
If dgvSearch.RowCount = 0 Then
lblmessage.Text = "There are no locations found under this search criteria"
dgvSearch.Visible = False
grboxSelectFile.Visible = False
Exit Sub
End If
grboxSelectFile.Visible = True
lblmessage.Text = "Records found :" & dgvSearch.RowCount
dgvSearch.Visible = True
dgvSearch.DefaultCellStyle.Font = New Font("Verdana", 8, FontStyle.Regular)
dgvSearch.AlternatingRowsDefaultCellStyle.Font = New Font("Verdana", 8, FontStyle.Regular)
dgvSearch.EnableHeadersVisualStyles = False
dgvSearch.ColumnHeadersDefaultCellStyle.BackColor = Color.DarkGreen
dgvSearch.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.DarkGreen
dgvSearch.ColumnHeadersDefaultCellStyle.Font = New Font("Verdana", 8, FontStyle.Bold)
dgvSearch.Columns("Customer_ID").DisplayIndex = 1
dgvSearch.Columns("Customer_ID").ReadOnly = True
dgvSearch.Columns("Customer_ID").HeaderText = "Customer Id"
dgvSearch.Columns("Customer_ID").Visible = True
dgvSearch.Columns("Customer_Name").Width = 170
dgvSearch.Columns("Customer_Name").DisplayIndex = 2
dgvSearch.Columns("Customer_Name").ReadOnly = True
dgvSearch.Columns("Customer_Name").HeaderText = "Cuastomer Name"
dgvSearch.Columns("Address1").Width = 170
dgvSearch.Columns("Address1").DisplayIndex = 3
dgvSearch.Columns("Address1").ReadOnly = True
dgvSearch.Columns("Address1").HeaderText = "Address1"
dgvSearch.Columns("City").Width = 90
dgvSearch.Columns("City").DisplayIndex = 4
dgvSearch.Columns("City").ReadOnly = True
dgvSearch.Columns("City").HeaderText = "City"
dgvSearch.Columns("State").Width = 45
dgvSearch.Columns("State").DisplayIndex = 5
dgvSearch.Columns("State").ReadOnly = True
dgvSearch.Columns("State").HeaderText = "State"
dgvSearch.Columns("Zip").Width = 90
dgvSearch.Columns("Zip").DisplayIndex = 6
dgvSearch.Columns("Zip").ReadOnly = True
dgvSearch.Columns("Zip").HeaderText = "Zip"
dgvSearch.Columns("Phone").Width = 100
dgvSearch.Columns("Phone").DisplayIndex = 7
dgvSearch.Columns("Phone").ReadOnly = True
dgvSearch.Columns("Phone").HeaderText = "Phone"
dgvSearch.Columns("CustAuthFileName").Width = 130
dgvSearch.Columns("CustAuthFileName").DisplayIndex = 8
dgvSearch.Columns("CustAuthFileName").ReadOnly = True
dgvSearch.Columns("CustAuthFileName").HeaderText = "FileName"
dgvSearch.Columns("CustAuthFileName").Visible = True
dgvSearch.Columns("ID").Visible = False
dgvSearch.Columns("MDS_RECNUM").Visible = False
dgvSearch.Columns("Fax").Visible = False
dgvSearch.Columns("Address2").Visible = False
dgvSearch.Columns(0).DisplayIndex = 1
dgvSearch.Columns(1).Width = 25
dgvSearch.Columns(1).DisplayIndex = 0
dgvSearch.Columns(1).HeaderText = ""
dgvSearch.Columns(0).ReadOnly = True
Catch ex As Exception
DisplayError(ex)
LogApplicationsErrors(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, Me.Name)
End Try
End Sub