Vaggelis Charalabakis
Top achievements
Rank 1
Vaggelis Charalabakis
asked on 10 Jun 2010, 10:20 AM
What i want is to right click on a row of a radGridView then
rise up a contextmenustip for the user to click a button and get the current row index from the right click
How can i do this?
3 Answers, 1 is accepted
0
Accepted
Hello Vaggelis Charalabakis,
Thank you for writing.
You can replace the default context menu with a custom one in ContextMenuOpenning event. In the menu item Click event handler, you can get the index of the grid's current row, which will be the index of right-clicked row. Please consider the following code:
I hope this helps. Let me know if you have any other questions.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for writing.
You can replace the default context menu with a custom one in ContextMenuOpenning event. In the menu item Click event handler, you can get the index of the grid's current row, which will be the index of right-clicked row. Please consider the following code:
void
radGridView1_ContextMenuOpening(
object
sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
if
(
this
.radGridView1.CurrentRow
is
GridViewDataRowInfo)
{
RadDropDownMenu menu =
new
RadDropDownMenu();
RadMenuItem menuItem =
new
RadMenuItem(
"Get row index"
);
menuItem.Click +=
new
EventHandler(menuItem_Click);
menu.Items.Add(menuItem);
e.ContextMenu = menu;
}
}
void
menuItem_Click(
object
sender, EventArgs e)
{
int
index =
this
.radGridView1.Rows.IndexOf(
this
.radGridView1.CurrentRow
as
GridViewDataRowInfo);
MessageBox.Show(String.Format(
"Current row index is: {0}"
, index));
}
I hope this helps. Let me know if you have any other questions.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rabeeh
Top achievements
Rank 2
answered on 15 Jul 2010, 01:18 PM
How can I get the index of the row that the mouse just moved over, I hooked to the event
RowMouseMove it gives me the row but of type GridDataRowElement
I can get the index of a row of type GridViewDataRowInfo using this.myGrid.Rows.IndexOf(myRow), how can the get the index of the row of type GridDataRowElement or GridRowElement ???
Thank you
0
Hi Rabeeh ,
Thank you for the question.
You can get the row info from the particular row element through the RowInfo property:
Hope this is helpful. Let me know if you have any additional questions.
All the best,
Martin Vasilev
the Telerik team
Thank you for the question.
You can get the row info from the particular row element through the RowInfo property:
GridDataRowElement row = e.RowElement;
int
rowIndex =
this
.radGridView1.Rows.IndexOf(row.RowInfo);
Hope this is helpful. Let me know if you have any additional questions.
All the best,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items