Databound GridViewComboBoxColumn Problem

2 posts, 0 answers
  1. Chris Kirkman
    Chris Kirkman avatar
    37 posts
    Member since:
    Jul 2012

    Posted 19 Apr 2011 Link to this post

    I have a column defined in my gridview.  It's name is "Energy".

    I use the following code to bind my object to it.  The object is a generic List<> of other objects.

     

     

    ((

     

    GridViewComboBoxColumn)m_grd.Columns["Energy"]).DataSource = m_snc.Configuration.CurrentRadiationDevice.Energies;

     

     

     

     


    The binding seems to work fine as far as display is concerned.  Each "Energy" object has a ToString() override which allows me to see what I want in cases where I bind it to drop down's (like in this case).  The combo box is filled with the appropriate display values; however when I select an item from the combo box and check to see the value's type, it is always a System.String instead of the object type of the item that is selected.  In this case the expected behavior of the following method would be my custom object's type instead of System.String.

     

     

    row.Cells["Energy"].Value.GetType()

  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 22 Apr 2011 Link to this post

    Hello Chris,

    Thank you for your question.

    The type of a GridViewComboBoxColumn cell value is the type of the column's ValueMember. You can discover the type of the displayed in the column object using column's DataSource.

    I hope it helps.

    Best regards,
    Alexander
    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top