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?
MariaHaltAsked:
Who is Participating?
 
Mortaza DoulatyConnect With a Mentor Commented:
Try to add some DoEvents in lines with your code!
Seems funny but may help, for example:

  DoEvents
  Text1.Setfocus
  DoEvents
0
 
Mortaza DoulatyCommented:
Add a code to handle the  MSHFlexGrid1_LeaveCell event.
0
 
MariaHaltAuthor Commented:
I have code in the  MSFlexGrid_LeaveCell Event that saves any changes made.  

What exactly are you suggesting that I add?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Mortaza DoulatyCommented:
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...
0
 
MariaHaltAuthor Commented:
Yes, I do both.  That's what makes this puzzling.  
0
 
MariaHaltAuthor Commented:
It worked!  Thank you!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.