Hi, please help me on this. i've searched everywhere but seems like noting working and it's stressed me out
i have a gridview and need to enable row click event to get the ID of the users.
currently, im able to click at each cell and display the value belong to it. but it should only display the ID of the row even we click different cell (in the same row).
i dont want this function occur at headers. how to do this? and can it works if we dont display the ID in the gridview?
i disclose my codes below
please help me guys, it's very urgent...tq
xaml:
code behind:
i have a gridview and need to enable row click event to get the ID of the users.
currently, im able to click at each cell and display the value belong to it. but it should only display the ID of the row even we click different cell (in the same row).
i dont want this function occur at headers. how to do this? and can it works if we dont display the ID in the gridview?
i disclose my codes below
please help me guys, it's very urgent...tq
xaml:
<telerik:RadGridView Grid.Row=
"1"
x:Name=
"radGridView"
telerik:Theming.Theme=
"Expression_Dark"
HorizontalAlignment=
"Stretch"
VerticalAlignment=
"Stretch"
AutoGenerateColumns=
"False"
IsReadOnly=
"True"
CanUserFreezeColumns=
"False"
RowIndicatorVisibility=
"Collapsed"
Margin=
"0,0,0,27"
ShowGroupPanel=
"False"
>
<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding No}"
Header=
"No."
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Adm_Date}"
Header=
"Date Admission"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Name}"
Header=
"Name"
/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
code behind:
this
.radGridView.AddHandler(GridViewCell.MouseLeftButtonDownEvent,
new
MouseButtonEventHandler(MouseDownOnCell),
true
);
private
void
MouseDownOnCell(
object
sender, MouseButtonEventArgs e)
{
try
{
object
cellValue = ((UIElement)e.OriginalSource).ParentOfType<GridViewCell>().Value;
MessageBox.Show(
"Click on : "
+ cellValue.ToString());
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
return
;
}
}