Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Right-Click HELP please!

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Right-Click HELP please!
Link Posted: 03-Jan-2006 10:38
I have a FlyGrid that does NOT allow multi-row selection.

When Users right-click on a node, I want to SELECT the node they are right-clicking on AND I want to UNSELECT all other selected nodes (since this FlyGrid doesnt allow multi-selection, there SHOULD only be ONE other node currently selected.)

Can you please give a VB.NET example of how to accomplish this simple task?   Nothing I try is working

Kindest regards,
Curtis Smith
Data Recognition Corporation
Link Posted: 16-Jan-2006 05:18
Could you offer any suggestion on how to correct this?
Thanks!

-LK
Link Posted: 16-Jan-2006 08:48
Use FlyGrid.NodeSelectedChange event handler:
[VB.Net]
Private Sub InitializeComponent()
   '.....
   ' to handle right selection include GridOptions.RightSelection
   '  option into FlyGrid.Options
   Me.flyGrid.Options = flyGrid.Options Or GridOptions.RightSelection
End Sub

' NodeSelectedChange event handler
Private Sub treeviewGrid_NodeSelectedChange(ByVal sender As Object, ByVal node As NineRays.Windows.Forms.Data.NodeBase) Handles flyGrid.NodeSelectedChange
  If (node.RightSelected) Then
    Me.flyGrid.Selected = node
  End If
End Sub
Link Posted: 25-Jan-2006 10:01
Two comments:  First, your code produces an infinate-loop since setting the Selected Node causes the NodeSelectedChange to fire - where we set it again, etc. etc. round and round.

Second:  It ALMOST works.  This selects the right-clicked Node but then it instantly vanishes as the Selected Node for some reason.


I'm not sure why you're handling the Right-Click so differently than the Left-Click but it seems to me (about about 99.99% of the other developers out there) that Left and Right clicks should act exactly the same.  If the developer wants different behavior, he/she can see which button was clicked on and take actions accordingly.

The way you have it right now, it's almost impossible to get a right-click pop-up menu without a ton of code and a ton of monkeying around.  This has gone far beyond frustrating

-LK
Link Posted: 25-Jan-2006 10:33
[quote="Elkay"]Two comments:  First, your code produces an infinate-loop since setting the Selected Node causes the NodeSelectedChange to fire - where we set it again, etc. etc. round and round.

Yes, in the NodeSelectedChange should be used a flag that indicating current state:
[VB.Net]
Private as processedNode as NodeBase
Private Sub InitializeComponent()
   '.....
   ' to handle right selection include GridOptions.RightSelection
   '  option into FlyGrid.Options
   Me.flyGrid.Options = flyGrid.Options Or GridOptions.RightSelection
End Sub

' NodeSelectedChange event handler
Private Sub treeviewGrid_NodeSelectedChange(ByVal sender As Object, ByVal node As NineRays.Windows.Forms.Data.NodeBase) Handles flyGrid.NodeSelectedChange
  If (node.RightSelected And Not node.Equals(processedNode)) Then
    processedNode = node;
    Me.flyGrid.Selected = node
    processedNode = Nothing;
  End If
End Sub

[quote="Elkay"]
Second:  It ALMOST works.  This selects the right-clicked Node but then it instantly vanishes as the Selected Node for some reason.

I'm not sure why you're handling the Right-Click so differently than the Left-Click but it seems to me (about about 99.99% of the other developers out there) that Left and Right clicks should act exactly the same.  If the developer wants different behavior, he/she can see which button was clicked on and take actions accordingly.

The way you have it right now, it's almost impossible to get a right-click pop-up menu without a ton of code and a ton of monkeying around.  This has gone far beyond frustrating

-LK


To get a right-click menu you can use MouseDown/MouseUp event handlers and use FlyGrid.RightClickNode to determine right-clicked node or use this in popup menu initialization/click code.
Link Posted: 20-Mar-2007 01:34
I am having same problem.

What I have done:


        NodeBase p = null;
        private void flyGrid1_NodeSelectedChange(object sender, NodeBase node)
        {
            if (node.RightSelected && !node.Equals(p))
            {
                p = node;
                flyGrid1.Selected = node;
                p = null;
            }
        }


If you right-click on a row grid loose selection completely.

And by the way - I dont know what was the reason to have Selected and RightSelected but for us - developers - it brings only confusion...

Cheers
Link Posted: 20-Mar-2007 04:56
But why you you don't use FlyGrid.RightClickNode to determine selected by right-click node?
Link Posted: 20-Mar-2007 06:52
No no.. One second. Let me put it in new thread. Cos I see here some misunderstanding..
Link Posted: 19-Jun-2007 08:29
Did we find a resolution to this, I am running into same issue. Basically I want the right node to remain selected after the context menu shows up and user want to select one of the menu options.
Link Posted: 05-Jul-2007 21:19
There is no proper solution as whole thing is twisted. Than deeper I go then more frustrating it turns out...

Here is the code I use...

        void Grid_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (Grid.RightClickNode != null)
                {
                        ShowContextMenu();
                }
            }
        }