rt
我想做一个“打开方案”的操作界面,界面中由一个datagrid与access数据库相连,我想让用户点一行记录,然后再单击旁边的“打开”按钮就能把所选的记录加载。现在点datagrid只能选中一格,而不能选中一行,各位帮我。

解决方案 »

  1.   

    如果是为了点选一行的话,很简单
    右击DataGrid,选择属性>>拆分>>选取框样式中的3-dbgHighLightRow
    另:加载是什么意思呢?详细一点吧
      

  2.   

    guofengx(ttx) :我是想单击datagrid中的任意一个cell,就能使整行都高亮显示,同时能获得
          所选那行的某一个字段的值。
     kuangyulai(不务正业) :我不想用listview做,因为不符合我的应用要求
     9raul(唯我) :你说的方法的确能使整行都高亮显示。但出现了一个问题:我做了个试验,目的是只要鼠标单击datagrid任意一个格子(包括记录导航栏),都能在旁边的一个textbox中显示那一格所在的记录行中的某个字段,参看下面的代码:'datagrid1中共有两列显示ado中的两个字段
    With datagrid1
     If .Col < 3 Then
      Text1.Text = .Columns(1).Value
     End If
    End With我在datagrid1_click()和datagrid1_mouseup()中试着加入上面的代码,结果,每次都是单击一个cell,text1中显示的是上一次单击的cell所在记录行的内容!
    这是不是跟焦点的获取有关系??
      

  3.   

    Private Sub grdDataGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    With grdDataGrid
     If .Col < 3 Then
      Text1.Text = .Columns(0).Value
     End If
    End With
    End Sub
      

  4.   

    Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
           DataGrid1.MarqueeStyle = dbgHighlightRow       '加亮选中一行 
           DataGrid1.Col = 0
     End Sub