?
Solved

Keeping a MSFlexgrid highlighted when not in focus

Posted on 2003-03-05
6
Medium Priority
?
839 Views
Last Modified: 2007-12-19
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
Comment
Question by:BirdsOfFire1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
supunr earned 800 total points
ID: 8077239
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
 
LVL 11

Expert Comment

by:supunr
ID: 8077246
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
 

Expert Comment

by:SantoshShitole
ID: 8077455
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!

 

Author Comment

by:BirdsOfFire1
ID: 8084685
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
 

Expert Comment

by:SantoshShitole
ID: 8086534
trap the EnterCell event and
MGrid.Row will give u the seleted row of grid
0
 

Author Comment

by:BirdsOfFire1
ID: 8093899
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question