• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 778
  • Last Modified:

MSFLEXGRID control setting focus to wrong field

I have an MSFLEXGRID control on a form. I am loading it from a recordset and when I click on a row, I have that row of items (plus quite a few more fields related to that item) load into textboxes on the form. All of this works beautifully. I give the user the ability to update the textboxes and it will refresh the grid... all is good.

My problem is whenever the grid loses focus and then I click on a row in the grid it selects the 1st field of the 1st column. The next click works fine. It's only when the grid is getting focus back that it always selects the same field... no matter where I click. How can I get the grid to select the proper row (or cell) when I click on it when the grid is getting focus?
0
md0333
Asked:
md0333
  • 3
  • 3
1 Solution
 
game-masterCommented:

good morning!

can i see ur code on the click event of the flexgrid.
do you also have code on the gotfocus?


game-master
0
 
md0333Author Commented:
I call another sub from the Click event.... but the problem comes immediately. I have the grid SelectionMode as FlexSelectionByRow.  Anytime I click on a Row it gives me the value for the 1st field (Which is a Deal Number) in the row.

Private Sub MSFlexGrid1_Click()
     giDealNum = MSFlexGrid1.Text   'Set Deal Number Variable
     getGridInfo MSFlexGrid1.Text     'Send Deal Number and Load Customer info screen
End Sub

I use that deal number to build my select statement and load all of the textboxes on the screen.  Problem is if the Grid does not have focus and I select a row in the grid it will always bring back the Deal Number from the 1st row. It doesn't make a difference if I put the code in the click event or in the gotfocus event... still comes back as row 1.

I've tried changing the SelectionMode to flexSelectionFree but that doesn't help either...


0
 
game-masterCommented:


good afternoon.
try this approach...


Private Sub MSFlexGrid1_Click()
     giDealNum =  MSFlexGrid1.TextMatrix( MSFlexGrid1.Row, 0)
     getGridInfo giDealNum     'Send Deal Number and Load Customer info screen
End Sub

explanation of MSFlexGrid1.TextMatrix( MSFlexGrid1.Row, 0):

this means that your getting the value on the selected row and on column 0 (column number depends on the column value that u want to get)

i hope this could give u idea.

game-master
of the flexgrid.

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
md0333Author Commented:
already tried this... If the grid does not have focus when I click on it... No matter where I click on the grid it always comes back with row 1. So even if I click on row 10... It comes back 1. Once the grid has focus everything works great.
0
 
md0333Author Commented:
OK... I've figured out what is causing the problem. Now I need help to figure out how to do what I want to do...

Once again, I have a grid with about 10 fields of information on it. When the user clicks on the grid it will load all of that information plus a lot more related to that Deal number in textboxes above the grid. If the user needs to change any information they can do it from the textboxes and on the Lost_focus event of those textboxes it will update the DB and then refresh the grid to match the information that has just changed.

If the lost_focus of a textbox goes to the next textbox everything is great. The DB updates and the grid refreshes properly. But if the user moves from one of those textboxes straight to the grid the DB updates and the Grid Refreshes but the on_click event of the grid doesn't happen until after the grid has been refreshed and then it just brings back the 1st row, 1st field value... Why?

I would think that the lost_Focus event of the textbox would be complete before the on_Click of the grid happens. I'm not sure why that 1st click in the grid is not working properly.
 
0
 
game-masterCommented:


good morning!
that is what the flexgrid works..everytime the flexgrid was on focus the 1st column and 1st row is always selected.

i suggest that u need to create a variable that holds the selected row.
And finally put the cursor on the row( variable holds) when u got the
gotfocus event.


game-master
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.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now