This is a migrated thread and some comments may be shown as answers.

get column name of the current cel

2 Answers 219 Views
GridView
This is a migrated thread and some comments may be shown as answers.
loraine
Top achievements
Rank 1
loraine asked on 17 Apr 2011, 01:07 PM
hi! how can i get the column name of the current cell in the radgridview?
RadGridView1 is the name of my datagrid.
these doesn't work:
 
RadGridView1.CurrentCell.Column.ToString();
RadGridView1.CurrentCellInfo.Column.ToString();
RadGridView1.CurrentColumn.ToString();

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 18 Apr 2011, 07:26 AM
Hi Loraine,

 

If you need to access the column name of the current cell just add its UniqueName as shown below:

private void btn_Click(object sender, RoutedEventArgs e)
        {
            var cell = this.radGridView.CurrentCell.Column.UniqueName;
            MessageBox.Show(cell);
        }

MainPage.xaml:

<telerik:RadGridView x:Name="radGridView" SelectionUnit="Cell" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn UniqueName="col1" DataMemberBinding="{Binding Age}" Header="Age"/>
                <telerik:GridViewDataColumn UniqueName="col2" DataMemberBinding="{Binding FirstName}" Header="First Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="Last Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Married}" Header="Is Married"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>


The code you have used will return the type of the column. If you do not specify the UniqueName for a column, the snippet above will return the underlying property to which the column is bound to.
 


Regards,
Vanya Pavlova
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
loraine
Top achievements
Rank 1
answered on 18 Apr 2011, 12:40 PM
thanks Telerik team!!! you're the best :)
Tags
GridView
Asked by
loraine
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
loraine
Top achievements
Rank 1
Share this question
or