Hi,
I have a RadGridView,it contains various columns.i marked two columns of them IsVisible = False, on certain condition.
I have another condition, on which one of the invisible columns mark IsVisible = True, But i am not able to get index of recently marked visible column on RowLoaded event.
On RowLoaded event i am unable to get "Address" column index.
XAML :
I have a RadGridView,it contains various columns.i marked two columns of them IsVisible = False, on certain condition.
I have another condition, on which one of the invisible columns mark IsVisible = True, But i am not able to get index of recently marked visible column on RowLoaded event.
//This is to hide two columns "Address" and "LastName"
private void rdbHide_Checked(object sender, RoutedEventArgs e) { if ((bool)rdbHide.IsChecked) { dgQueue.Columns["Address"].IsVisible = false; dgQueue.Columns["LastName"].IsVisible = false; }
dgQueue.Rebind();
} //This is to show "Address" column
private void rdbShow_Checked(object sender, RoutedEventArgs e) { if ((bool)rdbShow.IsChecked) dgQueue.Columns["Address"].IsVisible = true;
dgQueue.Rebind(); }On RowLoaded event i am unable to get "Address" column index.
private void dgQueue_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) { if (e.DataElement != null) { GridViewRow GrdRow = e.Row as GridViewRow; Emp objEV = e.Row.DataContext as Emp; if (GrdRow != null) { for (int index = 0; index < GrdRow.Cells.Count; index++) {
//Here i am not able to get index of "Address" column, on the bases of Address i want to show and hide Image control inside "PatInfo" column
if (GrdRow.Cells[index].Column.UniqueName.Equals("PatInfo")) { Image img = null; img = (Image)GrdRow.Cells[index].Content; if (!string.IsNullOrEmpty(objEV.Address)) { if (objEV.Address == "Noida") { if (img != null) img.Visibility = System.Windows.Visibility.Collapsed; } else { if (img != null) img.Visibility = System.Windows.Visibility.Visible; } } } } } } }XAML :
<telerik:RadGridView Name="dgQueue" Grid.Row="0" AutoGenerateColumns="False" RowLoaded="dgQueue_RowLoaded"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Width="*" UniqueName="FirstName" DataMemberBinding="{Binding FirstName}" Header="FirstName"> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Width="*" UniqueName="LastName" DataMemberBinding="{Binding LastName}" Header="LastName"> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Width="*" UniqueName="Address" DataMemberBinding="{Binding Address}" Header="Address" /> <telerik:GridViewDataColumn Width="*" UniqueName="Mobile" DataMemberBinding="{Binding Mobile}" Header="Mobile" /> <telerik:GridViewDataColumn Name="PatInfo" UniqueName="PatInfo" Width="90" Header="Pat Info"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <Image Name="imgDemo" Width="16" Height="16" ToolTip="Patient Information" Source="/WpfDemo;component/Images/magnify3.png" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>