Bad row index
Posted
#1
(In Topic #911)
Enthusiast

I have a problem that I don't know how to solve.
I use the MouseDown event to change a popupmenu.
I do something like this.
Code (gambas)
- ' In the following line I get the error: GridView1.Row (Bad row index)
- GridView1.PopupMenu = Popup1.Name
- GridView11.PopupMenu = Popup2.Name
But when I try to do a previous query to see if you have records and thus determine whether to put a popup menu or another, it returns the following error.
And I don't know how to do the previous consultation to change the popupmenu.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Regular

Public Sub GridView1_MouseDown()
If GridView1.Row < 0 Then
' either display some message like "No row selected" or just
Return
End If
If Mouse.Right Then …
hth
b
Posted
Enthusiast

but when I do the same with MouseDown, then since the click on the row has not occurred, it tells me the error, so I don't know what to do.
– Maybe if someone tells me how to get the popup menu by code maybe this is the solution. –
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

I come from the previous version (3.12) of Gambas and in this I am new (3.15.2)
I notice that the Click() event changed to MouseDown and MouseUp but what I didn't know and it's very convenient is that now the event that occurs on the right click is now unambiguous with the Menu() event, now the right event is well separated from the left.
So it is solved thanks to the Menu() event where I detect completely clear that the user presses the right click and therefore I execute the same code and I know the clicked row and I open the appropriate popup.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

PS, you should always prefer the MouseUp event to the MouseDown one.
Using MouseUp and Mouse.Inside() you can do the thing where if you click on something you can move the mouse away from it before letting the button go to cancel the click.
Another possibility is to NOT use the
GridView1.PopupMenu = Popup1.Name
instead leave the PopupMenu blank so it does not try to do anything and use the command Popup1.Popup() or Popup2.Popup() instead. That way you are in control of the action.
like…
Posted
Enthusiast

Although I have solved it I believe well. You give me very interesting information to renew my code and update my knowledge.
Thank you, you are really very kind. Some day I will help you in your code, but it may not happen, since I suppose you are a better Gambas developer than me.
Greetings.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

gambafeliz said
Thank you very much
Although I have solved it I believe well. You give me very interesting information to renew my code and update my knowledge.
Thank you, you are really very kind. Some day I will help you in your code, but it may not happen, since I suppose you are a better Gambas developer than me.
Greetings.
All roads lead to Rome they say
Just a note for the Menu event (that is also a good solution
If you do not want the menu to pop up if nothing is selected (this will happen if right click not on a list item) then do the following..
Code (gambas)
- ' In the following line I get the error: GridView1.Row (Bad row index)
- GridView1.PopupMenu = "Popup1"
- GridView11.PopupMenu = "Popup2"
Happy coding
1 guest and 0 members have just viewed this.


