修改
grid的selectmode在cilck event 中 form.show
=====================
www.myvc.net
编程技术论坛欢迎你的加盟!

解决方案 »

  1.   

    看看这个,会对你有帮助的
    Attribute VB_Name = "frmset"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Public sctj1 As String
    Public sctj2 As String
    Public irs As New ADODB.Recordset
    Private Sub Command1_Click()
    If txtzt1.Text = "" Then
     MsgBox "请输入服务器名"
      txtzt1.SetFocus
    End If
     If Czt1.Text = "" Then
       MsgBox "请选择主帐套名称"
     Exit Sub
     
    End If
    WritePrivateProfileString "ServerInfo", "Server", txtzt1.Text, App.Path + "\pz.ini"
    WritePrivateProfileString "ZtInfo", "Zt1", Czt1.Text, App.Path + "\pz.ini"WritePrivateProfileString "ZtInfo", "ND", Czt3.Text, App.Path + "\pz.ini"
    WritePrivateProfileString "ZtInfo", "PWD", txtmm.Text, App.Path + "\pz.ini"
    G_strServer = txtzt1.Text
    G_strZt1 = "UFDATA" & "_" & Left(Czt1.Text, 3) & "_" & Trim(Str(Czt3.Text))frmset.WindowState = 1
    End SubPrivate Sub Command2_Click()
    Dim msgtc As String
    msgtc = MsgBox("是否关闭自动导帐程序.", vbYesNo)
    If msgtc = vbNo Then
      Exit Sub
    End If
    RemoveFromTray
    Unload Me
    End
    End SubPrivate Sub Command3_Click()
    G_lngFF = 0
    Set G_Lrs = G_Lconn.Execute("select stime,iss from plan ")
      If Not G_Lrs.EOF Then
         If G_Lrs!iss = 1 Then
              G_lngFF = 1
             frmtimeset.Check1.Value = 1
          
         End If
       End Iffrmtimeset.Show 1End SubPrivate Sub Command4_Click()End SubPrivate Sub Form_Activate()
    Dim irs As New ADODB.Recordset
    G_blnIsEof = False
    If G_strServer <> "N" And G_strZtdb1 <> "N" Then
       txtzt1.Text = G_strServer
       If G_strPwd = "N" Then
        txtmm.Text = ""
        Else
        txtmm.Text = G_strPwd
       End If
       Czt1.Clear
      
       Czt1.Text = G_strZtdb1
      
       Czt3.Text = G_strNd
    End If
     
     i = 1
    End SubPrivate Sub Form_Initialize()
      
     Set G_Lrs = G_Lconn.Execute(" select iss from plan where iss=1 ")
      Set irs = G_Lconn.Execute("select * from  ufzt")
      If Not G_Lrs.EOF And Not irs.EOF Then
         Timer1.Enabled = True
        Else
         Timer1.Enabled = False
      End If
    End SubPrivate Sub Form_Load()Set G_Lrs = G_Lconn.Execute("select * from ufzt")
      
      While Not G_Lrs.EOF
         G_intId = G_intId + 1
         With ListView1.ListItems
            .Add , "XX" & G_intId, G_intId
            .Item("XX" & G_intId).SubItems(1) = G_Lrs!ztid & "_" & G_Lrs!ztname
            .Item("XX" & G_intId).SubItems(2) = G_Lrs!iyear
            .Item("XX" & G_intId).SubItems(3) = "***************"
         End With
        G_Lrs.MoveNext
     WendEnd SubPrivate Sub Form_Unload(Cancel As Integer)
    RemoveFromTray
    End SubPrivate Sub Labsyslog_Click()End SubPrivate Sub GurhanCoolButton1_CLICKED()
    frmlog.Show 1
    End SubPrivate Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    sctj1 = Item.SubItems(1)
    sctj2 = Item.SubItems(2)End SubPrivate Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Thenfrmset.PopupMenu mnu2
    End IfEnd SubPrivate Sub mnuadd_Click()
    frmzt.Show 1
    End SubPrivate Sub mnudel_Click()
      Dim G_lngRe As Long
        If sctj1 = "" Or sctj2 = "" Then
          Exit Sub
        End If   sctj1 = Left(sctj1, 3)
       
        G_lngRe = MsgBox("要删除该记录吗?", vbYesNo + vbQuestion, "提示信息")
        If G_lngRe = vbYes Then
           G_Lconn.Execute ("delete from ufzt where ztid='" & sctj1 & "' and iyear='" & sctj2 & "'")
           G_Lconn.Execute ("delete from pzid where ztid='" & sctj1 & "' and iyear='" & sctj2 & "'")
           ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
        End If
       sctj1 = ""
       sctj2 = ""
    End SubPrivate Sub Sg_Click()
     Set G_Lrs = G_Lconn.Execute("select * from ufzt")
      If G_Lrs.EOF Then
        MsgBox "没有设置子帐套信息,不能进行帐务传输工作"
       Exit Sub
      End If
     
     frmcl.Show 1
    End SubPrivate Sub Tc_Click()
     
     Unload frmset
    End Sub
    Private Sub Timer1_Timer()
     Dim strtime As String
     strtime = Format(Now, "hh:mm")
       
      Set G_Lrs = G_Lconn.Execute("select stime,iss from plan where  stime>='" & strtime & "'")
        If G_Lrs.EOF Then
           
           Exit Sub
        End If
      G_Lrs.MoveFirst
      While Not G_Lrs.EOF
          If G_Lrs!stime = strtime Then
             frmcl.Show 1
          End If
          If G_blnIsEof Then
           Exit Sub
          End If
        G_Lrs.MoveNext
     WendEnd SubPrivate Sub Timer2_Timer()
     Set G_Lrs = G_Lconn.Execute(" select iss from plan where iss=1 ")
      Set irs = G_Lconn.Execute("select * from  ufzt")
      If Not G_Lrs.EOF And Not irs.EOF Then
         Timer1.Enabled = True
        Else
         Timer1.Enabled = False
      End If
    If frmset.WindowState = 1 Then
          frmset.Visible = False
    End IfEnd SubPrivate Sub txtmm_LostFocus()
    If txtzt1.Text = "" Then
       MsgBox "请输入服务器名"
       txtzt1.SetFocus
     End If
     
    If G_Ufconn.State <> adStateClosed Then
      G_Ufconn.Close
    End IfG_Ufconn.ConnectionString = "Provider=SQLOLEDB.1;Password=" & txtmm.Text & ";Persist Security Info=True;User ID=sa;Initial Catalog=UFsystem;Data Source=" & txtzt1.Text
    On Error GoTo Er:
    G_Ufconn.Open
    Set G_Ufrs = G_Ufconn.Execute("SELECT cAcc_G_intId ,cacc_name From UA_Account GROUP BY cAcc_G_intId,cacc_name")
     Czt1.Clear While Not G_Ufrs.EOF
          Czt1.AddItem ufrs!cAcc_G_intId + "-" + ufrs!cacc_name
          
         G_Ufrs.MoveNext
     WendExit SubEr:
      MsgBox "连接服务器失败"
      
    End SubPrivate Sub txtzt1_LostFocus()
    'If txtzt1.Text = "" Then
    '   MsgBox "请输入服务器名"
    '   txtzt1.SetFocus
    ' End If
    '
    'If G_Ufconn.State <> adStateClosed Then
    '  G_Ufconn.Close
    'End If
    'G_strPwd = txtmm.Text
    'G_Ufconn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=SA;password=" & G_strPwd & ";Initial Catalog=UFSystem;Data Source=" & Trim(txtzt1.Text)
    'On Error GoTo Er:
    '
    'G_Lconn.Execute ("delete from pzid")
    '
    'G_Ufconn.Open
    '
    'Set UFrs = G_Ufconn.Execute("SELECT cAcc_G_intId ,cacc_name From UA_Account GROUP BY cAcc_G_intId,cacc_name")
    ' Czt1.Clear
    '
    ' While Not UFrs.EOF
    '      Czt1.AddItem UFrs!cAcc_G_intId + "-" + UFrs!cacc_name
    '
    '     UFrs.MoveNext
    ' Wend
    '
    'Exit Sub
    '
    'Er:
    '  MsgBox "连接服务器失败"
    '
    End SubPrivate Sub Ztset_Click()
    frmset.WindowState = 0
    frmset.Visible = TrueEnd Sub
      

  2.   

    我用的是true datagrid ,没有人再指点一下嘛