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

GridViewCheckBoxColumn displays True/False instead of check box when deriving GridViewRowInfo

2 Answers 244 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 03 Jan 2013, 04:33 PM
I have an issue with RadControls for WinForms Q3 2012 where calling Rows.Add with an instance of a type inheriting from GridViewRowInfo causes the value in a GridViewCheckBoxColumn to display True/False instead of a check box. The following illustrates the issue:

using Telerik.WinControls.UI;
 
namespace TestApp {
    partial class MainForm : RadForm {
        public MainForm() {
            InitializeComponent();
            ItemGrid.Rows.Add(new CustomRowInfo(ItemGrid, "Item #1", true));
            ItemGrid.Rows.Add(new CustomRowInfo(ItemGrid, "Item #2", false));
        }
 
        private class CustomRowInfo : GridViewRowInfo {
            public CustomRowInfo(RadGridView owner, string text, bool enabled)
                : base(owner.MasterView) {
                Cells[0].Value = text;
                Cells[1].Value = enabled;
            }
 
            public string Text {
                get { return Cells[0].Value.ToString(); }
                set { Cells[0].Value = value; }
            }
 
            public bool Enabled {
                get { return (bool) Cells[1].Value; }
                set { Cells[1].Value = value; }
            }
        }
    }
}


What am I doing wrong?
Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 08 Jan 2013, 09:30 AM
Hello Tom,

You should add a GridViewCheckBoxColumn to enable check box for each cell. You can read more about that in the online documentation. After I read your code snippet, I recommend changing the base class of your custom row to be GridViewDataRowInfo, which represents a logical row that keeps data in RadGridView.

Kind regards, Svett
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Tom
Top achievements
Rank 1
answered on 09 Jan 2013, 01:47 PM
Fantastic, thank you very much!
Tags
GridView
Asked by
Tom
Top achievements
Rank 1
Answers by
Svett
Telerik team
Tom
Top achievements
Rank 1
Share this question
or