RadGridView when AutoGeneratingColumn Column.ItemType is null

5 posts, 1 answers
  1. W
    W avatar
    14 posts
    Member since:
    Apr 2016

    Posted 28 Apr Link to this post

    RadGridView when AutoGeneratingColumn(Event or override OnAutoGeneratingColumn) Column.ItemType is null.

    How can I get ItemType?

  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 28 Apr Link to this post

    Hello,

    You can use ItemPropertyInfo argument of AutoGeneratingColumn event - args.ItemPropertyInfo.PropertyType .

    I hope this helps.

    Regards,
    Yoan
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft banner
  4. W
    W avatar
    14 posts
    Member since:
    Apr 2016

    Posted 28 Apr Link to this post

    Not PropertyType.

    GridViewColumn.ItemType's summary : Gets the type of the item that the field belongs to.

    GridView's items or ItemsSource is IEnumerable<T> or DataItemCollection or some type else.

    How to get the item type "T" in AutoGeneratingColumn?

    Is there any way to get "T" direct, not judge by GridView's items or ItemsSource?

  5. Answer
    Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 03 May Link to this post

    Hello,

    I am afraid that you can not use the ItemType property of GridViewColumn in AutoGeneratingColumn. However, you can use the GridView's Items property. In fact, the GridViewColumn.ItemType property is using a similar approach:
    /// <summary>
            /// Gets the type of the item that the field belongs to.
            /// </summary>
            /// <value>The type of the item.</value>
            public virtual Type ItemType
            {
                get
                {
                    if (this.DataControl != null)
                    {
                        return this.DataControl.Items.ElementType;
                    }

    However, ElementType is internal, so you can't use it directly.

    Regards,
    Yoan
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  6. W
    W avatar
    14 posts
    Member since:
    Apr 2016

    Posted 06 May in reply to Yoan Link to this post

    Thank you for answer me!

    But "ElementType" is not public.So that only judged indirectly.

Back to Top
DevCraft banner