如题:
小弟初学vb,望大侠们指教!

解决方案 »

  1.   

    Dim K As BooleanPrivate Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 Then
    K = Not K
    If K = False Then ON_CLICK
    End If
    End SubPrivate Sub Form_Load()
    K = False
    End Sub
      

  2.   

    指教:如何选中datagrid中的一条纪录,双击触发一个on_click事件 
    //你这个问题很奇怪啊选种datagrid的记录直接去点就行了on_click事件是你写的吗?不管是不是直接去call就行了
      

  3.   

    Private Sub DataGrid1_DblClick()
        Call Command1_Click'双击调用Command1的单击事件
        '要调用其他时间类似地写就行了: Call 事件名称
    End Sub
      

  4.   

    给你双击触发的例子
    Private Sub DataGrid1_DblClick()
       On Error Resume Next
       Dim strsql As String
       '向datagrid4中写入数据
       txt_fkid.Text = ""
       txt_jhid.Text = DataGrid1.Columns(0)
       strsql = "select jh_id as ID,dw_mc as 单位名称,jh_sbmc as 设备名称,jh_gg as 规格型号,"
       strsql = strsql & " jh_dw as 单位,jh_dj as 单价,jh_sl as 数量,jh_bfsl as 报废数量,jh_btsl as 补套数量,"
       strsql = strsql & " jh_ptsl as 配套数量,jh_je as 金额,jh_bfje as 报废金额,jh_btje as 补套金额  ,jh_ptje as  配套金额,"
       strsql = strsql & " jh_fl as 设备编码 ,jh_cj as 厂家 ,jh_hb as 货币 ,jh_bz as 备注 ,jh_year as  年份"
       strsql = strsql & " from jhtz_dw_view"
       strsql = strsql & " where jh_id=" & txt_jhid.Text
       Set Db = New Connection
       Db.CursorLocation = adUseClient
       Db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\计划管理系统.mdb;Persist Security Info=False"
       Set adoPrimaryRS = New Recordset
       adoPrimaryRS.Open strsql, Db, adOpenStatic, adLockOptimistic
       Set DataGrid4.DataSource = adoPrimaryRS
       DataGrid4.Columns(0).Visible = False
       Set Db = Nothing
       '如果fk_table里有和txt_jhid匹配的数据,那么在datagrid2中显示
       strsql = "select * from jhtz_fk_view where jh_id=" & txt_jhid.Text
       Set rs = ExecuteSQL(strsql, msgtext)
       If rs.RecordCount > 0 Then
          Do While Not rs.EOF
             If txt_fkid.Text = "" Then
                txt_fkid.Text = rs.Fields("fk_id")
             Else
                txt_fkid.Text = txt_fkid.Text & "," & rs.Fields("fk_id")
             End If
             rs.MoveNext
          Loop
       Else
          txt_fkid.Text = ""
       End If
       
       strsql = "select fk_id as ID,fk_wczcje_bh as 完成资产流水号,fk_wczcje as 完成资产金额,fk_yfkje_bh as 预付款流水号, fk_yfkje as 预付款金额,fk_fkje_bh as 付款流水号,fk_fkje as 付款金额"
       strsql = strsql & " from fk_table"
       strsql = strsql & " where jh_id=" & txt_jhid.Text
       Set Db = New Connection
       Db.CursorLocation = adUseClient
       Db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\计划管理系统.mdb;Persist Security Info=False"
       Set adoPrimaryRS = New Recordset
       adoPrimaryRS.Open strsql, Db, adOpenStatic, adLockOptimistic
       Set DataGrid2.DataSource = adoPrimaryRS
       DataGrid2.Columns(0).Visible = False
       Set Db = Nothing
    End Sub
      

  5.   

    to: faysky2() 
    不好意思,我说的不清楚!
    我不想在datagrid中,删除,修改,添加
    我的想法是选中一条纪录后,双击弹出窗体,进行上面我所说的操作!
      

  6.   

    我建议你改用rowcolchange事件,click和dbclick用在datagrid都会有问题
      

  7.   

    我的想法是选中一条纪录后,双击弹出窗体,进行上面我所说的操作!
    ------------------------------
    Private Sub DataGrid1_DblClick()
        Form1.Show '双击弹出窗    
    End Sub