Index of column

2 posts, 0 answers
  1. Frank
    Frank avatar
    7 posts
    Member since:
    Jul 2015

    Posted 29 Mar 2016 Link to this post

    Does the IndexOf() method from GridColumnCollection return a zero based index? 

    What will be returned if the column wasn´t found?




    Remark to:


    GridColumnCollection cols = grid.MasterTableView.Columns;

    GridColumn c = cols.FindByUniqueName(columnName);

    if (c != null)



    FindByUniqueName throws a GridException if the column wasn´t found.

    So why testing c for null?






  2. Viktor Tachev
    Viktor Tachev avatar
    2501 posts

    Posted 30 Mar 2016 Link to this post

    Hello Frank,

    The GridColumnCollection is a zero-based collection. Thus, the first item in the collection will have 0 as index.

    Thank you for noting that the FindByUniqueName() method will throw an exception if the column is not found. In order to avoid the exception you can use the FindByUniqueNameSafe() method.

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top