8 个解决方案
#1
是不是這樣子
1.右鍵修改datagird的屬性資料行。
2.Private Sub P_Grid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
End Sub
1.右鍵修改datagird的屬性資料行。
2.Private Sub P_Grid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
End Sub
#2
2.Private Sub dataGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
datagrid.BackColor = vbyellow
End Sub
datagrid.BackColor = vbyellow
End Sub
#3
進入到datagrid控件的屬性里面﹐找到對應數據的列﹐改成相應的名稱﹐
第二種方法
Private Sub Form_Load()
Dim strConn As String
Dim pubConn As New ADODB.Connection
Dim rsTable As New ADODB.Recordset
Dim strSQL As String
strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=develop; password=12345;Data Source=ServerName"
pubConn.Open strConn
rsTable.CursorLocation = adUseClient
strSQL = "select col1 as 字段1,col2 as 字段2.... from TableName" -->注意這個select語句里要給出這個字段的中文別名
rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rsTable
End Sub
第二種方法
Private Sub Form_Load()
Dim strConn As String
Dim pubConn As New ADODB.Connection
Dim rsTable As New ADODB.Recordset
Dim strSQL As String
strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=develop; password=12345;Data Source=ServerName"
pubConn.Open strConn
rsTable.CursorLocation = adUseClient
strSQL = "select col1 as 字段1,col2 as 字段2.... from TableName" -->注意這個select語句里要給出這個字段的中文別名
rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rsTable
End Sub
#4
datagrid无法改变颜色,建议换控件
#5
建议用mshflexgrid,可以轻松设置每个单元格的格式
#6
用mshflexgrid控件可以設置每一個單元格的顏色,但mshflexgrid不能修改數據
#7
还有一个问题,grid控件默认可以修改它的数据,那有没有办法让用户不可以编辑某一列数据只可以编辑其他列的数据??
#8
在DataGrid控件上按右鍵,選擇<屬性>在里面的<版面配置>選項卡下可以設置哪一列可編輯,哪一列鎖定,默認是全部可以編輯的
#1
是不是這樣子
1.右鍵修改datagird的屬性資料行。
2.Private Sub P_Grid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
End Sub
1.右鍵修改datagird的屬性資料行。
2.Private Sub P_Grid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
End Sub
#2
2.Private Sub dataGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
datagrid.BackColor = vbyellow
End Sub
datagrid.BackColor = vbyellow
End Sub
#3
進入到datagrid控件的屬性里面﹐找到對應數據的列﹐改成相應的名稱﹐
第二種方法
Private Sub Form_Load()
Dim strConn As String
Dim pubConn As New ADODB.Connection
Dim rsTable As New ADODB.Recordset
Dim strSQL As String
strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=develop; password=12345;Data Source=ServerName"
pubConn.Open strConn
rsTable.CursorLocation = adUseClient
strSQL = "select col1 as 字段1,col2 as 字段2.... from TableName" -->注意這個select語句里要給出這個字段的中文別名
rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rsTable
End Sub
第二種方法
Private Sub Form_Load()
Dim strConn As String
Dim pubConn As New ADODB.Connection
Dim rsTable As New ADODB.Recordset
Dim strSQL As String
strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=develop; password=12345;Data Source=ServerName"
pubConn.Open strConn
rsTable.CursorLocation = adUseClient
strSQL = "select col1 as 字段1,col2 as 字段2.... from TableName" -->注意這個select語句里要給出這個字段的中文別名
rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rsTable
End Sub
#4
datagrid无法改变颜色,建议换控件
#5
建议用mshflexgrid,可以轻松设置每个单元格的格式
#6
用mshflexgrid控件可以設置每一個單元格的顏色,但mshflexgrid不能修改數據
#7
还有一个问题,grid控件默认可以修改它的数据,那有没有办法让用户不可以编辑某一列数据只可以编辑其他列的数据??
#8
在DataGrid控件上按右鍵,選擇<屬性>在里面的<版面配置>選項卡下可以設置哪一列可編輯,哪一列鎖定,默認是全部可以編輯的