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?
md0333Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.