MSHFlexGrid控件中的当Combo1还有焦点时,此时点击MSHFlexGrid控件中的水平滚动条,Combo1会不停的移动?如何解决?
MSHFlexGrid控件中除了第3列是用下拉列表来选择的,其他列是用文本框来选择的...
现在问题
1 如果Combo1还有焦点时,此时点击MSHFlexGrid控件中的水平滚动条,Combo1会不停的移动?如何解决这种现象?
2 使用Text1.Move -10000, -10000, 1, 1后,双击进行文本框内,无法自动选择里面的内容,好象看不到光标在文本框内闪烁的效果,不直观,去除了这句后Text1.Move -10000, -10000, 1, 1 效果又成了不能文本框不会随着点击的地方不同而自动更改?如何解决??
我的代码如下:
Private Sub Combo1_Change() ''加了这个事件就能使得选择完了之后,能让MSHFlexGrid1.Text 的内容为Combo1.Text
MSHFlexGrid1.Text = Combo1.Text
Combo1.Visible = False
End Sub
Private Sub Combo1_LostFocus() '加了这个事件就不会在Combo1控件失去焦点时,还会看Combo控件的影子,
MSHFlexGrid1.Text = Combo1.Text
Combo1.Visible = False
End Sub
Private Sub Form_Load()
Text1.Move -10000, -10000, 1, 1
adoCnn.Open "Provider=sqloledb;server=.;Database=sxcpmc;Uid=sa;Pwd=;"
Rs.CursorLocation = adUseClient
Rs.Open "select * from BOM0 ", adoCnn, adOpenDynamic, adLockBatchOptimistic
Set MSHFlexGrid1.DataSource = Rs
Combo1.Visible = False
End Sub
Private Sub MSHFlexGrid1_Click()
If Combo1.Visible = True Then
Combo1.Visible = False
MSHFlexGrid1.CellBackColor = &H80000005 'white
End If
If MSHFlexGrid1.Col = 3 Then
Combo1.Width = MSHFlexGrid1.CellWidth
Combo1.Left = MSHFlexGrid1.CellLeft + MSHFlexGrid1.Left
Combo1.Top = MSHFlexGrid1.CellTop + MSHFlexGrid1.Top
Combo1.Text = MSHFlexGrid1.Text
Combo1.Visible = True
End If
End Sub
Private Sub MSHFlexGrid1_EnterCell()
MSHFlexGrid1.CellBackColor = vbBlue
MSHFlexGrid1.CellForeColor = vbWhite
Text1.Text = MSHFlexGrid1.Text
Text1.SelStart = 0
Text1.SelLength = Len(MSHFlexGrid1.Text) 'len(text1.text)'
End Sub
Private Sub MSHFlexGrid1_LeaveCell()
MSHFlexGrid1.CellBackColor = vbWhite
MSHFlexGrid1.CellForeColor = vbBlue
If MSHFlexGrid1.Col = 3 Then
MSHFlexGrid1.Text = Trim(Combo1.Text) '' Format$(FlxGd, "#") 'alpha-number format
End If
MSHFlexGrid1.CellBackColor = &H80000005
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If MSHFlexGrid1.Col = 3 Then
Combo1.Text = Combo1.List(1)
Else
Text1.SetFocus
End If
End Sub
'
Private Sub Text1_Change()
MSHFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown
KeyCode = 0
End Select
End Sub
[最优解释]
在mshflexgrid控件的scroll事件中处理一下combo1的visible属性
[其他解释]