I need to make all but 2 of the columns in the datagridview readonly.
Can I do this? How? Below is my code.
Dim MySqlConnection As New SqlClient.SqlCo nnection
Dim MySqlCommand As New SqlClient.SqlCo mmand
Dim MySqlAdapter As New SqlClient.SqlDa taAdapter
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
MySqlConnection .ConnectionStri ng = "packet size=4096;user ....."
If ShowPostedToolS tripMenuItem.Ch ecked Then
MySqlCommand.Co mmandText = "select * from Checks"
Else
MySqlCommand.Co mmandText = "select * from Checks where Post
= 0"
End If
MySqlCommand.Co nnection = MySqlConnection
MySqlAdapter.Se lectCommand = MySqlCommand
DataGridView1.D ataSource = mydt
mydt.Clear()
mydt.Columns.Cl ear()
Try
MySqlAdapter.Fi ll(mydt)
Catch ex As Exception
MessageBox.Show ("Error: " & ex.Message)
Exit Sub
End Try
End Sub
Can I do this? How? Below is my code.
Dim MySqlConnection As New SqlClient.SqlCo nnection
Dim MySqlCommand As New SqlClient.SqlCo mmand
Dim MySqlAdapter As New SqlClient.SqlDa taAdapter
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
MySqlConnection .ConnectionStri ng = "packet size=4096;user ....."
If ShowPostedToolS tripMenuItem.Ch ecked Then
MySqlCommand.Co mmandText = "select * from Checks"
Else
MySqlCommand.Co mmandText = "select * from Checks where Post
= 0"
End If
MySqlCommand.Co nnection = MySqlConnection
MySqlAdapter.Se lectCommand = MySqlCommand
DataGridView1.D ataSource = mydt
mydt.Clear()
mydt.Columns.Cl ear()
Try
MySqlAdapter.Fi ll(mydt)
Catch ex As Exception
MessageBox.Show ("Error: " & ex.Message)
Exit Sub
End Try
End Sub
Comment