GridViewCheckBoxColumn unchecks on horizontal scroll

4 posts, 0 answers
  1. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 09 May 2012 Link to this post

    I have a GridView with a databound GridViewCheckBoxColumn.  When the checkbox is checked and I scroll horizontally where the checkbox is no longer visible and then scroll back, the checkbox loses its checked state, though the data source still indicates it should be checked.
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 May 2012 Link to this post

    Hello Jes, 

    I haven't been able to replicate your issue. Are you doing some sort of formatting on the row or the cell that might be affecting this? 

    In the meantime, here is a sample to try out. 

    Designer
    namespace RadControlsWinFormsApp1
    {
        partial class RadForm1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
     
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
     
            #region Windows Form Designer generated code
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
                this.SuspendLayout();
                //
                // radGridView1
                //
                this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radGridView1.Location = new System.Drawing.Point(0, 0);
                this.radGridView1.Name = "radGridView1";
                this.radGridView1.Size = new System.Drawing.Size(135, 383);
                this.radGridView1.TabIndex = 0;
                this.radGridView1.Text = "radGridView1";
                //
                // RadForm1
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(135, 383);
                this.Controls.Add(this.radGridView1);
                this.Name = "RadForm1";
                //
                //
                //
                this.RootElement.ApplyShapeToControl = true;
                this.Text = "RadForm1";
                this.ThemeName = "ControlDefault";
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
                this.ResumeLayout(false);
     
            }
     
            #endregion
     
            private Telerik.WinControls.UI.RadGridView radGridView1;
     
     
     
        }
    }

    Form
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using Telerik.WinControls.UI;
    using System.Linq;
     
    namespace RadControlsWinFormsApp1
    {
        public partial class RadForm1 : Telerik.WinControls.UI.RadForm
        {
            public RadForm1()
            {
                InitializeComponent();
     
                List<User> users = new List<User>();
                int k = 0;
                while (k <= 20)
                {
                    bool hasBeard = (k % 2 == 0);
                    users.Add(new User(k, "User " + k.ToString(), hasBeard));
                    k++;
                }
     
                this.radGridView1.DataSource = users;
            }
     
        }
     
        public class User
        {
            public User(int id, string name, bool hasBeard)
            {
                Id = id;
                Name = name;
                HasBeard = hasBeard;
            }
     
            public User()
            { }
     
            public int Id
            {
                get;
                set;
            }
     
            public string Name
            {
                get;
                set;
            }
     
            public bool HasBeard
            {
                get;
                set;
            }
        }
     
    }

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 May 2012 Link to this post

    Hello Jes,

    I am not aware of such issues either. Could you please provide us with your application code so we can investigate it and provide you with a solution for this case.  As Richard mentioned, it is most likely that some formatting code causes this issue.

    I am looking forward to hearing from you.

    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  5. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 14 May 2012 Link to this post

    I fixed this by making the column in the data source a type of bool.
Back to Top