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

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
0
BirdsOfFire1
Asked:
BirdsOfFire1
  • 2
  • 2
  • 2
1 Solution
 
supunrCommented:
Set the following properties of the grid.

Grid1.FocusRect = 0 ' Focus None
Grid1.Highlight = 1 ' Highlight always
Grid1.SelectionMode = 1 ' Selection by Row

Good Luck!
0
 
supunrCommented:
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.
0
 
SantoshShitoleCommented:
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BirdsOfFire1Author Commented:
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

0
 
SantoshShitoleCommented:
trap the EnterCell event and
MGrid.Row will give u the seleted row of grid
0
 
BirdsOfFire1Author Commented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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