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

MSHFlexGrid - Row Selection

Status
Not open for further replies.

bzac

Programmer
Dec 20, 2000
55
US
Here I have one problem like when the user double clicks on the mshflexgrid for selecting a row, some times it will return the correct row number or else return -1 row number. I can't figure out why it is happening, Please give me some solution.

This is the Code:-

Private Sub mshgridcustomer_DblClick()
If mshgridCustomer.Rows > 0 Then
With mshgridCustomer
'.Row = .MouseRow + 1
.Row = .MouseRow
.Col = 0
unitid = .Text
txtid.Text = unitid
:::::::::::::::
End Sub

Thank You.
 
This is some code I used to mark a flex grid row with the color red if it was clicked on. If the row clicked was already marked as red, then the color was turned off.

Private Sub Flex_Click()
' if we clicked on a row marked with red, then
' we will unmark the row and exit the routine
If Flex.MouseRow = 0 Then Exit Sub
CurrentRow = Flex.Row
' if the row is red(was selected on a prior click) turn it off !
If PriorRowSelected > 0 Then
Flex.Row = PriorRowSelected
For J = 0 To Flex.Cols - 1
Flex.Col = J
Flex.CellBackColor = 0
Next J
cmdView.Enabled = False
cmdAdd.Enabled = False
cmdDelete.Enabled = False
If CurrentRow = PriorRowSelected Then
PriorRowSelected = 0
Exit Sub
End If
End If
PriorRowSelected = 0
' Now, finally, we get to mark the selected row with red
Flex.Row = CurrentRow
If IsNumeric(Flex.TextMatrix(Flex.Row, 0)) Or IsDate(Flex.TextMatrix(Flex.Row, 0)) Then
Flex.Row = CurrentRow
Flex.Col = 1
For J = 0 To Flex.Cols - 1
Flex.Col = J
Flex.CellBackColor = vbRed
Next J
' at this point the row is marked and ready for to be processed
 
bzac
You are using mouserow to get the current clicked row of the flexgrid.
this statement which you had used always works fine ,if there is no fixedrow in your flexgrid.

With mshgridCustomer
.Row = .MouseRow

if there is any fixed row in your flexgrid then you have to use something like this.

with mshgridCustomer
.Row + 1 = .MouseRow

assuming that you have 1 fixed row in your flexgrid.




 
Thank you very much RayMan and altctldel, I will try your ideas. Anyway I always used one Fixed row on MSHFlexgrid in this program and I tried ".Row = .MouseRow + 1" and ".Row = .MouseRow", but getting different values in different instances.

I am looking for some more ideas. Thank you verymuch in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top