谁有用vsflexgrid控件作为表格,大批量录入数据的例子?最好带有校验功能的,比如某列录入数据时该数据必须在另一个表中能查找到,否则不能跳出单元格

解决方案 »

  1.   

    FindRow你看看这个属性,
    你的意思能不能说的具体点
      

  2.   

    那你不如用vsflexgrid的combolist属性让人选择好些,所能选择的只能是表中的数据
      

  3.   

    Private Sub Grid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
        '//變成已修改===================================================
        Checkx = True
        '//單元格變換===================================================
        Select Case Grid1.Col
            Case 2 '//自已輸入布料編號時================================
                If Not (Me.ActiveControl Is Grid1) Then Exit Sub
                If Trim(Grid1.Cell(flexcpText, Row, Col)) <> "" Then
                    If OpenDBase(Cloth_Cloth_QS3(Cloth_Cloth_SortxStr, "Cloth_Cloth_NO='" & Grid1.EditText & "'")) = False Then
                        InputErrRow1 = Row
                        InputErr1 = True
                        If x_Rs.State = 1 Then x_Rs.Close
                        Grid1.Select InputErrRow1, 2
                        Exit Sub
                    End If
                    If x_Rs.RecordCount = 0 Then
                        InputErrRow1 = Row
                        InputErr1 = True
                        If x_Rs.State = 1 Then x_Rs.Close
                        Grid1.Select InputErrRow1, 2
                        Xtxxts "布料資料庫中還未存在相關資料,請先輸入布料其本資料!", 0, 3
                        Exit Sub
                    End If
                    If x_Rs.RecordCount > 1 Then
                        InputErrRow1 = Row
                        InputErr1 = True
                        If x_Rs.State = 1 Then x_Rs.Close
                        Grid1.Select InputErrRow1, 2
                        Xtxxts "布料資料庫中存在多個相同布號!", 0, 3
                        Exit Sub
                    End If
                    Grid1.Cell(flexcpData, Grid1.Row, 2) = x_Rs.Fields("Cloth_Cloth_ID").Value
                    Grid1.Cell(flexcpText, Grid1.Row, 3) = IIf(IsNull(x_Rs.Fields("Base_Color_NameC").Value), "", x_Rs.Fields("Base_Color_NameC").Value)
                    Grid1.Cell(flexcpText, Grid1.Row, 4) = IIf(IsNull(x_Rs.Fields("Base_Color_Value").Value), "", x_Rs.Fields("Base_Color_Value").Value)
                    Grid1.Cell(flexcpText, Grid1.Row, 20) = IIf(IsNull(x_Rs.Fields("Base_Unit_Name").Value), "", x_Rs.Fields("Base_Unit_Name").Value)
                    Grid1.Cell(flexcpText, Grid1.Row, 22) = IIf(IsNull(x_Rs.Fields("Cloth_Cloth_FD").Value), "", x_Rs.Fields("Cloth_Cloth_FD").Value)
                    Grid1.Cell(flexcpText, Grid1.Row, 27) = IIf(IsNull(x_Rs.Fields("Cloth_SM_Name1").Value), "", x_Rs.Fields("Cloth_SM_Name1").Value)
                    InputErr1 = False
                Else
                    Grid1.Cell(flexcpData, Grid1.Row, 2) = ""
                    Grid1.Cell(flexcpText, Grid1.Row, 3) = ""
                    Grid1.Cell(flexcpText, Grid1.Row, 4) = 16777215 '白色
                    Grid1.Cell(flexcpText, Grid1.Row, 20) = ""
                    Grid1.Cell(flexcpText, Grid1.Row, 22) = ""
                    Grid1.Cell(flexcpText, Grid1.Row, 27) = ""
                    InputErr1 = False
                End If
            End Select
    End SubPrivate Sub Grid1_EnterCell()
        '//網格單元格成為焦點時=========================================
        '//輸入錯誤的布料編號就死鎖在那個錯誤格=========================
        If InputErr1 = True And (InputErrRow1 <> Grid1.Row Or Grid1.Col <> 2) Then
            Grid1.Select InputErrRow1, 2
            Grid1.ShowCell InputErrRow1, 2
            Xtxxts "布料編號輸入錯誤!", 0, 3
        End If
    End Sub