Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I select Row on RightClick?
Message
From
08/09/2008 22:40:26
John Baird
Coatesville, Pennsylvania, United States
 
 
To
08/09/2008 10:46:21
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01345747
Message ID:
01345941
Views:
17
>The reason that I want to do this is because I am using a context menu to allow users to add, edit and delete item (it calls up a modal dialog). It is a little confusing to them if they right click, select edit or delete, and the information from a different row shows up in the modal dialog.
>
>TIA


Hi Marcia,

Farhad's idea might work, but the standard way (if there is one), is to use the grid hittest. Here is a sample from a compact app of mine, I've deleted a bunch of code from it to make it smaller, but you should get the general idea:
        private void grdSeen_MouseUp(object sender, MouseEventArgs e)
        {
            DataGrid.HitTestInfo hti = this.grdSeen.HitTest(e.X, e.Y);
            const int seenColumn = 0;
            const int nameColumn = 1;
            const int countColumn = 2;
            try 
            {
                switch(hti.Type)
                {
                    case DataGrid.HitTestType.Cell:
                        {
                            this.grdSeen.Select(hti.Row);
                            switch (hti.Column)
                            {
                                case seenColumn:
                                    {
                                        this.SetData(hti.Row, hti.Column, (ChecklistItemDataSet.CheckListItemRow)_dtItem.Rows[hti.Row]);
                                        this.grdSeen.CurrentCell = new DataGridCell(hti.Row, hti.Column - 2);
                   		                break;
                                    }
                                case nameColumn:
                                    {
                                        // move off row so name highlights as selected row.
                                        this.grdSeen.CurrentCell = new DataGridCell(hti.Row, hti.Column - 1);
                                        break;
                                    }
                                case countColumn:
                                    {
                                        if (!Convert.ToBoolean(_dtItem.Rows[hti.Row]["Seen"]))
                                        {
                                            //if it hasn't been marked seen, mark it and record data
                                            this.SetData(hti.Row, hti.Column, (ChecklistItemDataSet.CheckListItemRow)_dtItem.Rows[hti.Row]);
                                        }
                                        else
                                        {
                                            //just incrmeent the count.
                                            this.IncrementCount((ChecklistItemDataSet.CheckListItemRow)_dtItem.Rows[hti.Row]);
                                        }
                                        this.grdSeen.CurrentCell = new DataGridCell(hti.Row, hti.Column);
                                        break;
                                    }
                            }
                            break;
                        }
                    case DataGrid.HitTestType.ColumnHeader:
                        {
                              break;
                        }
                }
            }
            catch(Exception ex) 
            { 

               MessageBox.Show(ex.ToString()); 

            } 
        }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform