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

How to know the index of one GridViewCell

2 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jackey
Top achievements
Rank 1
Jackey asked on 21 Mar 2015, 04:55 AM
Hi team,
I am using CellStyleSelector documented in this link. However, in the following code 
public override Style SelectStyle(object item, DependencyObject container)
 {
  if (item is Club)
  {
   Club club = item as Club;
   if (club.StadiumCapacity > 50000)
   {
    return BigStadiumStyle;
   }
   else
   {
    return SmallStadiumStyle;
   }
  }
  return null;
 }
I want to know the column index of the GridViewCell. I know the container object is type of GridViewCell. However i don't know how to continue. I read some class documentation, finding no proper ways. Any ideas?

Thanks,
Jingfei

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 21 Mar 2015, 09:31 AM
Hello,

You could find the column associated with he cell passed as the container argument. The code to access it would be similar to this one:

GridViewCell cell = container as GridViewCell;
var currentColumn = cell.Column as GridViewDataColumn;


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jackey
Top achievements
Rank 1
answered on 11 Apr 2015, 08:47 AM
Thanks a lot for your assistance, Dimitrina.
Tags
GridView
Asked by
Jackey
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jackey
Top achievements
Rank 1
Share this question
or