| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 419 人关注过本帖
标题:各位大侠,能否出手帮我想实现在MSFlexGrid1第3列弹出Combo1列表,其它都是用 ...
只看楼主 加入收藏
yiyaozjk
Rank: 2
等 级:论坛游民
帖 子:231
专家分:30
注 册:2010-3-10
结帖率:51.67%
收藏
 问题点数:0 回复次数:0 
各位大侠,能否出手帮我想实现在MSFlexGrid1第3列弹出Combo1列表,其它都是用文本输入??

这段时间被这个MSFlexGrid1 搞得头发晕,(控不住2行标题字符合并和字符对齐,文字一会儿居中对齐,一会儿左端对齐,一会儿只能行合并,列不能合并,)

各位大侠,能否出手帮我想实现在MSFlexGrid1第3列弹出Combo1列表,其它都是用文本在MSFlexGrid1输入??

运行时显示的错误为: 输入第一行到第2列时,在Text1.SetFocus 这行报错,  实时错误5,无效的过程调用或参数.

(能否帮我修改一下我的代码 实现上述红色功能 ,我都快晕了.....)代码如下:

Public zs As Integer
Public mrc As ADODB.Recordset
Public Sub classshowtitle()
 Dim i As Integer
 MSFlexGrid1.Clear
  With MSFlexGrid1
    .RowHeightMin = 400
    .RowHeight(0) = 500
    .Cols = 13
    .Rows = 2
 '   .TextMatrix(0, 1) = "序号"
 '   .TextMatrix(0, 2) = "产品编号"
 '   .TextMatrix(0, 3) = "产品名称"
    .TextMatrix(0, 1) = "工令单号"
    .TextMatrix(0, 2) = "客户单号"
    .TextMatrix(0, 3) = "货   号"
    .TextMatrix(0, 4) = "产品名称"
    .TextMatrix(0, 5) = "订单数量"
    .TextMatrix(0, 6) = "大枪完成数"
    .TextMatrix(0, 7) = "手绘完成数"
    .TextMatrix(0, 8) = "抹水油完成数"
    .TextMatrix(0, 9) = "其它部门1"
    .TextMatrix(0, 10) = "其它部门2"
    .TextMatrix(0, 11) = "其它部门3"
    .TextMatrix(0, 12) = "其它部门4"


'    .TextMatrix(0, 9) = "录入人员"
'    .TextMatrix(0, 10) = "输入日期"
    .ColWidth(0) = 10
    .ColWidth(1) = 1800
    .ColWidth(2) = 1600
    .ColWidth(3) = 1500
    .ColWidth(4) = 1200
    .ColWidth(5) = 1200
    .ColWidth(6) = 1200
    .ColWidth(7) = 1200
    .ColWidth(8) = 1200
    .ColWidth(9) = 1200
'    .ColWidth(9) = 1000
'    .ColWidth(10) = 1000
'    .ColWidth(11) = 1000
'    .ColWidth(12) = 1000
'    .ColWidth(13) = 1000
    .FixedRows = 1

    'For i = 0 To 9
    '   .CellFontBold = True
    '   .ColAlignment(i) = 0
   ' Next i
    .FillStyle = flexFillSingle
    .Col = 0
    .Row = 0
    .RowSel = 1
    .ColSel = .Cols - 1
    .CellAlignment = 0
    .Row = 1
    End With
End Sub

Private Sub Form_Load()
    Me.Top = 650
    Me.Left = 50
    Me.classshowtitle   '显示一下标题
    Me.Width = 15500
    Me.Height = 9500 'MDIForm1.Height
    Text1.Visible = False
    Combo1.Visible = False
   ' Me.classshowdata
End Sub
Private Sub Form_Activate()
   Dim mrc, mrc1 As ADODB.Recordset
    Combo1.Visible = False
    Combo2.Enabled = True
   txtsql = "select * from gongxu" '查询到所有参与的不同工单号及BOM表产品号
   Set mrc = ExecuteSQL(txtsql)
   txtsql = "select * from bom0" '查询到所有参与的不同工单号及BOM表产品号
   Set mrc1 = ExecuteSQL(txtsql)
    Dim xsy
    Dim j As Integer
    Dim i As Integer
   If mrc.EOF = True Then
      MSFlexGrid1.Clear
   Exit Sub
  End If
    mrc.MoveFirst
    Combo1.AddItem ""
    Do While Not mrc.EOF
      Combo1.AddItem Trim(mrc.Fields(2))
      mrc.MoveNext
    Loop
    ''   Combo2.AddItem ""
    Do While Not mrc1.EOF
       Combo2.AddItem Trim(mrc1.Fields(1))
       mrc1.MoveNext
    Loop
    zs = mrc1.RecordCount
    mrc.Close
    Set mrc = Nothing
    mrc1.Close
    Set mrc1 = Nothing
'    Text2(0).SetFocus
End Sub

Private Sub MSFlexGrid1_Click()
  If Combo1.Visible = True Then
      Combo1.Visible = False
      MSFlexGrid1.CellBackColor = &H80000005  'white
    Else
      If Text1.Visible = True Then
         Text1.Visible = False
         MSFlexGrid1.CellBackColor = &H80000005
      End If
    End If
  If MSFlexGrid1.Col <> 3 Then  ' And MSFlexGrid1.Row <= 12
     Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(MSFlexGrid1.Col)
     Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(MSFlexGrid1.Row)
     Text1.Width = MSFlexGrid1.ColWidth(MSFlexGrid1.Col)
     Text1.Height = MSFlexGrid1.RowHeight(MSFlexGrid1.Row)
     Text1 = MSFlexGrid1.Text
     Text1.Visible = True
     Text1.SetFocus
     MSFlexGrid1.CellBackColor = &H80000005
   End If

End Sub
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then
     If MSFlexGrid1.Col <= 1 And MSFlexGrid1.Row <= 12 Then
        Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(MSFlexGrid1.Col)
        Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(MSFlexGrid1.Row)
        Text1.Width = MSFlexGrid1.ColWidth(MSFlexGrid1.Col)
        Text1.Height = MSFlexGrid1.RowHeight(MSFlexGrid1.Row)
        Text1 = MSFlexGrid1.Text
        Text1.Visible = True
        Text1.SetFocus
     End If
  End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If MSFlexGrid1.Col <> 3 Then
  If KeyAscii = vbKeyEscape Then
     Text1.Visible = False
     MSFlexGrid1.SetFocus
     Exit Sub
  End If
  If KeyAscii = vbKeyReturn Then
     MSFlexGrid1.Text = Text1.Text
     If MSFlexGrid1.Col < 12 Then
        MSFlexGrid1.Col = MSFlexGrid1.Col + 1
     Else
      If MSFlexGrid1.Row + 1 = MSFlexGrid1.Rows Then
        MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
      Else
         MSFlexGrid1.Row = MSFlexGrid1.Row + 1
         MSFlexGrid1.Col = 1
      End If
     End If
     Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(MSFlexGrid1.Col)
     Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(MSFlexGrid1.Row)
     Text1.Width = MSFlexGrid1.ColWidth(MSFlexGrid1.Col)
     Text1.Height = MSFlexGrid1.RowHeight(MSFlexGrid1.Row)
     Text1 = MSFlexGrid1.Text
     Text1.SetFocus        输入到第2列时,在这行报错,实时错误5,无效的过程调用或参数
  End If
 End If
End Sub
Private Sub Advance_Cell()                  'advance to next cell
    With MSFlexGrid1
        .Highlight = flexHighlightNever     'turn off hi-lite
        If .Col < .Cols - 1 Then
          .Col = .Col + 1
        Else
          If .Row < .Rows - 1 Then
            .Row = .Row + 1                 'down 1 row
            .Col = 1                        'first column
          Else
            .Row = 1
            .Col = 1
          End If
        End If
        If .CellTop + .CellHeight > .Top + .Height Then
          .TopRow = .TopRow + 1             'make sure row is visible
        End If
        .Highlight = flexHighlightAlways    'turn on hi-lite
    End With
End Sub
Private Sub MSFlexGrid1_EnterCell()
    If MSFlexGrid1.Col = 3 Then
         Text1.Visible = False
        Combo1.Width = MSFlexGrid1CellWidth
        Combo1.Left = MSFlexGrid1.CellLeft + MSFlexGrid1.Left
        Combo1.Top = MSFlexGrid1CellTop + MSFlexGrid1.Top
        Combo1.Text = MSFlexGrid1.Text
        Combo1.Visible = True
    End If
   ' MSFlexGrid1.CellForeColor = &HFF
    MSFlexGrid1.CellBackColor = &HC0FFFF    'lt. yellow
    MSFlexGrid1.Tag = ""                    'clear temp storage
End Sub
Private Sub MSFlexGrid1_LeaveCell()
    MSFlexGrid1.CellBackColor = &H80000005
End Sub
Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
    Case 46                 '<Del>, clear cell
        MSFlexGrid1.Tag = MSFlexGrid1   'assign to temp storage
        MSFlexGrid1 = ""
  End Select
End Sub
搜索更多相关主题的帖子: 头发 Combo1 
2011-12-19 09:57
快速回复:各位大侠,能否出手帮我想实现在MSFlexGrid1第3列弹出Combo1列表,其它都 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.064795 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved