[RESOLVED] MsFlexGrid Select Only 1 row at time.
I am using a MSFlexGrid. Is there a quick and easy way to stop the user selecting more than one row at a time. I want the user to only be allowed to select one row.
Thanks
Kev
Albert Einstein - "The secret to creativity is knowing how to hide your sources."
Re: MsFlexGrid Select Only 1 row at time.
Re: MsFlexGrid Select Only 1 row at time.
yes, in the msflexgrid set the follow
FillStyle=0-Single
SelectionMode=1=By Row
Re: MsFlexGrid Select Only 1 row at time.
Hello ganeshmoorthy
unfortunately that is what I have already set. You still can select more than one row by dragging the mouse or using the shift key.
Is there anyway to disable this.
Kev.
Steve Martin - "A day without sunshine is like, you know, night"
Re: MsFlexGrid Select Only 1 row at time.
HI
If you right click the grid and select propertys or in propertyscreen(F4) you have the custom property
there you see
if you set the checkbox off where it says Allowbigselecion
and the selectionmode would help if you set it by Row
:thumb:
Re: MsFlexGrid Select Only 1 row at time.
I'm sorry for that please also
set the MergeCells =2-RestrictRows
Re: MsFlexGrid Select Only 1 row at time.
Thanks again, setting the property MergeCells =2-RestrictRows does, sort of work. The only problem I have now is that the row the user clicks on isn't highlighted.
Kev
Steven Wright - "It's a small world, but I wouldn't want to paint it. "
Re: MsFlexGrid Select Only 1 row at time.
is a cell getting highlighted
Re: MsFlexGrid Select Only 1 row at time.
It doesn't look like anything is getting highlighted.
I have written a small procedure on the click event that highlights the row selected. Just seems a lot of work.
Oh well.
Kev.
Re: MsFlexGrid Select Only 1 row at time.
Marvels
Had AllowBigSelection set to false and SelectionByRow, it didn't work, still allowed the user to select more than one row by dragging the mouse or using the shift key.
Thanks
Kev.
Re: MsFlexGrid Select Only 1 row at time.
Marvels
Had AllowBigSelection set to false and SelectionByRow, it didn't work, still allowed the user to select more than one row by dragging the mouse or using the shift key.
Thanks
Kev
Re: MsFlexGrid Select Only 1 row at time.
no matter what happens when you drag your cursor and highlight a lot of cells or rows, it is only the highlight that does it but in the selection sense, only one record will be selected. i'm sure of this,
the problem with this truth is that the user can be confused with the number of rows he selected
i have a proposal or shall we say, a suggestion for Kev, if you really want to select only a single row at a time, try to use listview
i know it very much that it is posible with listview coz thats the way all my applications work. try it and youll see your desired result.
i for myself will conclude that theres no way you can restrict the user to be able to highlight a single row only with msflexgrid. i dont know with the others, i would be glad if somebody could correct me if theres a way,
http://www.smileypad.com/v10/Cache/Misc/Want-Some.gif
Re: MsFlexGrid Select Only 1 row at time.
VB Code:
flexgrid.SelectionMode = flexSelectionByRow
Re: MsFlexGrid Select Only 1 row at time.
I have it working so that only one row is selected. The only way I could do it was as ganeshmoorthy suggested and then on the click event I manually highlighted the through VB Code as below.
Code:
Private Sub grdEstimatesFound_Click()
Dim i As Integer
Dim j As Integer
Dim intRow As Integer
With grdEstimatesFound
intRow = .Row
For j = 1 To .Rows - 1
.Row = j
If j = intRow Then
For i = 0 To .Cols - 1
.Col = i
.CellBackColor = vbHighlight
.CellForeColor = vbWhite
Next i
Else
For i = 0 To .Cols - 1
.Col = i
.CellBackColor = vbWhite
.CellForeColor = vbBlack
Next i
End If
Next j
.Row = intRow
End With
DoEvents
End Sub
That is the only way I could do it.
Kev.
Re: [RESOLVED] MsFlexGrid Select Only 1 row at time.
This is what I use
VB Code:
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
'Turns off the automatic Highlighting and colors the current row's
'background with the highlight color
With Me.MSFlexGrid1
.Redraw = False
.FillStyle = flexFillRepeat
.RowSel = .Row
.ColSel = .Cols - 1
.CellBackColor = .BackColorSel
.HighLight = flexHighlightNever
.FillStyle = flexFillRepeat
.Redraw = True
End With
End If
End Sub
Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
'Turns ON automatic Highlighting and resets the current row's
'background color to the default
With Me.MSFlexGrid1
.Redraw = False
.FillStyle = flexFillRepeat
.RowSel = .Row
.ColSel = .Cols - 1
.CellBackColor = .BackColor
.HighLight = flexHighlightAlways
.Redraw = True
End With
End If
End Sub
Private Sub MSFlexGrid1_SelChange()
MSFlexGrid1.RowSel = MSFlexGrid1.Row
End Sub
Private Sub Form_Load()
With MSFlexGrid1
.AllowBigSelection = False
.AllowUserResizing = flexResizeColumns
.Cols = 5
.Rows = 10
.SelectionMode = flexSelectionByRow
.FocusRect = flexFocusNone
End With
End Sub
This also works
VB Code:
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
MSFlexGrid1.Redraw = False
End If
End Sub
Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
MSFlexGrid1.Redraw = True
End If
End Sub
Private Sub MSFlexGrid1_SelChange()
MSFlexGrid1.RowSel = MSFlexGrid1.Row
End Sub