Link to home
Start Free TrialLog in
Avatar of MariaHalt
MariaHaltFlag for United States of America

asked on

Editing MSFlexgrid with TextBox, Problem with Keeping Focus on TextBox

I have a frame with 2 combo boxes, 3 label, 1 command button, 1 MSFlexgrid and 1 textbox.  

When a selection is made in both combo boxes, the MSFlexgrid is populated and appears.  The textbox is used to edit the non-fixed cells on the MSFlexgrid.  It seems to work OK at first, but when I click on another cell, the floating textbox won't keep the focus.  It reverts to the first combo box.  If I use the arrow keys to move to another cell, it keeps the focus.

textbox.TabStop = True (all other controls it's False)

In the MSFlexGrid_EnterCell Event I have the following code that is supposed to secure the focus on the textbox, it runs, but doesn't seem to do it's job all the time.

textbox.ZOrder (0)
textbox.Visible = True
textbox.SetFocus

How can I keep the focus on the textbox when clicked on?
Avatar of Mortaza Doulaty
Mortaza Doulaty
Flag of United Kingdom of Great Britain and Northern Ireland image

Add a code to handle the  MSHFlexGrid1_LeaveCell event.
Avatar of MariaHalt

ASKER

I have code in the  MSFlexGrid_LeaveCell Event that saves any changes made.  

What exactly are you suggesting that I add?
Have you tried this:

Private Sub MSHFlexGrid1_EnterCell()
  Text1.Setfocus
End Sub

Private Sub MSHFlexGrid1_Click()
  Text1.Setfocus
End Sub

In the "Click" event, setting the focus on text1, should solve the problem...
Yes, I do both.  That's what makes this puzzling.  
ASKER CERTIFIED SOLUTION
Avatar of Mortaza Doulaty
Mortaza Doulaty
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It worked!  Thank you!!!