Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msflexgrid with rectangle on entire row

sal21

Programmer
Joined
Apr 26, 2004
Messages
505
Location
IT
strongm, a few time ago, you post a code to create on click event on listview a regtangle with a thin border....
possible with a msflex grid on click event for entire row from > to?
Tks
 
As I recall, I pointed out that the requirement you had almost exactly described the existing behaviour as an msflexgrid.

So perhaps you can describe in more detail just exactly what you require that the msflexgrid does not do.

And I'll repeat the caution I raised then - try not to change the way a well-known control looks and operates unless you have a very, very good reason
 
strongm, i need this effect when i click on any cell or row, i think is a setfous or not?
Tks
 

Attachments

  • Immagine.gif
    Immagine.gif
    31.4 KB · Views: 6
It is built-ion behaviour for an msflexgrid, as previously advised. Apart from picking the right settings for the msflexgrid you don't have to do anything. Here's an example of setting up a demo grid:

Rich (BB code):
Option Explicit

Private Sub Form_Load()
    Dim i As Integer
   
    '  Initialize MSFlexGrid
    With MSFlexGrid1
        .Rows = 6  ' How many rows 
        .Cols = 4 ' Set number of columns
        .FixedRows = 1 ' One fixed header row
        .FixedCols = 0 ' No fixed columns
   
        '  Set column headers
        .TextMatrix(0, 0) = "ID"
        .TextMatrix(0, 1) = "Name"
        .TextMatrix(0, 2) = "Age"
        .TextMatrix(0, 3) = "City"
       
        '  Set column widths
        .ColWidth(0) = 1000
        .ColWidth(1) = 2000
        .ColWidth(2) = 1000
        .ColWidth(3) = 2000
       
        ' Add sample data
        For i = 1 To 5
            .TextMatrix(i, 0) = CStr(i)
            .TextMatrix(i, 1) = "Person " & CStr(i)
            .TextMatrix(i, 2) = CStr(20 + i * 5)
            .TextMatrix(i, 3) = Choose(i, "New York", "London", "Paris", "Tokyo", "Sydney")
        Next i
       
        '  up to you
        .BackColorSel = vbBlue
        .ForeColorSel = vbWhite
       
        .FocusRect = flexFocusNone ' Disable default focus rectangle
        .SelectionMode = flexSelectionByRow ' click selects entire row
        .HighLight = flexHighlightAlways ' Keep highlight even when grid loses focus
       
        '  Select the first data row
        .Row = 1
        .ColSel = .Cols - 1
    End With
End Sub
 
Yes – the MSFlexGrid already supports full-row highlighting on click. You just need to adjust a few properties in its setup:

With MSFlexGrid1
.FixedRows = 1
.FixedCols = 0
.BackColorSel = vbBlue
.ForeColorSel = vbWhite
.FocusRect = flexFocusNone ' hides the focus box
.SelectionMode = flexSelectionByRow
.HighLight = flexHighlightAlways ' keeps highlight even if grid loses focus

' (optional) pre-select first row:
.Row = 1
.ColSel = .Cols - 1
End With

Once configured this way, clicking any cell will automatically highlight the entire row with your custom colors—no extra painting or rectangle-drawing code needed.

Best Regards
local seo company sydney
 

Part and Inventory Search

Sponsor

Back
Top