Link to home
Start Free TrialLog in
Avatar of BirdsOfFire1
BirdsOfFire1

asked on

Keeping a MSFlexgrid highlighted when not in focus

I am using VB6.0 and an Access DB as a data storage with WIN2000.  I am using a MSFlexgrid to display a list of names.  Each name in the MSFlexgrid is unique. For each name listed in the MSFlexgrid, there are multiple for records in another table.  So you have a one to many table structure.  

I want to highlight a specific row in the MSFlexgrid and keep that row (name field in a row) highlighted while filling other boxes on the form.  Currently, when I click on a specific record in the MSFlexgrid and place the cursor in another field, the MSFlexgrid comes out of focus.  When this happens, the system can't find the row selected in the MSFlexgrid.  

I would like to keep the MSFlexgrid highlighted while the MSFlexgrid in not in focus.  When I press the submit button, the system is suppose to look for the row selected in the MSFlexgird.

Question!!!  How do you keep the row of a MSFlexgrid highlighted while operating on other controls (when not in focus)?


Thanks
The Firebird
ASKER CERTIFIED SOLUTION
Avatar of supunr
supunr

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
Avatar of supunr
supunr

As soon as you set the row of the grid to another value, it changes the selection to the new row.  So if you want to highlight a particular row, but want to change/fill other cells in a different row, use the "Grid.TextMatrix(RowVal, ColVal)" properties.
SET THIS PROPERTIES IN PROPERTY WINDOW
MGrid.FocusRect = 0
MGrid.Highlight = 1
MGrid.SelectionMode = 1

'PUT HIS CODE
   With MGrid
        .Row = 5  ' ROW TO BE SELECTED
        .Col = 0
        .ColSel = .Cols - 1
        .RowSel = .Row
    End With
Avatar of BirdsOfFire1

ASKER

To:  SantoshShitole

I tried this:

MGrid.FocusRect = 0
MGrid.Highlight = 1
MGrid.SelectionMode = 1

The code above doesn't work.

Do I put the code below on form load of the form?  Or do I set these values before give focus to another control?
'PUT HIS CODE
With MGrid
  .Row = 5  ' ROW TO BE SELECTED
  .Col = 0
  .ColSel = .Cols - 1
  .RowSel = .Row

Maybe, I should clarify.  When you select an item in a listbox, the listbox retains the highlighted item.  You can then determine what the value is for a specific row in the listbox after the listbox loses focus.  Say, you want to fill in textbox data elsewhere on the form.  The listbox retains the item selected until you put in the code "lst_listbox = "".  That clears the selected item in the listbox.

Does the MSFlexgrid have the same capability?  For example, will the code above cause the MSFlexgrid to retain the selected highlighted item after placing the cursor in a textbox on the same form?


Thanks
The Firebird

trap the EnterCell event and
MGrid.Row will give u the seleted row of grid
Oops,

I mistakenly had stray code in the form_load event making the MSFlexgrid "highlight on focus".  This was a syntax error and I deleted the code.

The system is working as intended.  Thanks for your assistance.



The Firebird