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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i select only 1 row of the data in the Ms FlexGrid 1

Status
Not open for further replies.

tansc81

Technical User
Mar 2, 2003
15
GB
How can i select only 1 row of the data in the Ms FlexGrid. the user is only allow to select 1 row at a time.. he cant drag the whole area
 
You'll need to monitor the mouseDown and mouseup events for the Flexgrid if you don't want the user to select more than one row. On mousedown, set the redraw property to false to not show the user more than the first row selected. On mouse up, if the Row property does not equal the RowSel, set the RowSel to equal .Row and turn the redraw property back to true.

Sub fg_MouseDown
fg.Redraw = false
End sub

Sub fg_MouseUp
if fg.row <> fg.rowsel then
fg.RowSel = fg.row
end if
fg.redraw = true
End sub

Mark
 
hey thanks for ur reply.. it works very well... but jsut another question. why i cant hightlight the whoel row? the first cloumn of the row is not hightlighted?
 
Set the SelectionMode property to flexSelectionByRow and the fg.Highlight to flexHighlightAlways, either in design mode or in runtime on teh Form_Load event.

Sub Form_Load
fg.SelectionMode = flexSelectionByRow
fg.HighLight = flexHighlightAlways
End Sub

Mark
 
I've already had these 2 statement in my code but it jsut didnt want to hightlight the first cloumn. The focus rect is on it but it' not hightlight!!
 

Turn off the focus rectange because you're selecting by row anyway:

fg.FocusRect = flexFocusNone

Mark
 
Thanks a lot!! argh.... such a small bug!!
 
sorry i have another question

I have a SStab with 3 tabs.. on the 2nd tab there is a MSflexGrid, which i can select by rows only. With i try to go to other tab and come back to the 2nd tab, the selected row in the MSflexGrid is not hightlighted, even thought grd1stLevel.RowSel have some value.

How can i make MSflexgird to hightlight on the row i previous selected when i come back form other tab?
 


If you're setting the fg.HighLight = flexHighlightAlways, it should remain selected regardless of which tab is selected. If it's not, then you might be doing something elsewhere that sets the .HighLight property to another setting.

You could always refresh the flexgrid on the SSTab1_Click event if SSTab1.Tab = the tab the flexgrid is on...

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top