or
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Telerik.WinControls.UI;using Telerik.WinControls.Enumerations;namespace RadGridViewProblems{ /* * Demonstate a gridview crash problem when quickly scrolling up and down and having row header column disabled, set * ShowRowHeaderColumn below to true and no crash anymore, reason why/workaround: unknown */ public partial class TestGridForm : RadForm { public TestGridForm() { InitializeComponent(); this.Load += new EventHandler(FormLoaded); } private void FormLoaded(object sender, EventArgs e) { //testGridView.ReadOnly = true; testGridView.AutoGenerateColumns = true; childGridViewTemplate = new GridViewTemplate(); childGridViewTemplate.AutoGenerateColumns = true; //set ShowRowHeaderColumn here to true and no crash anymore testGridView.MasterTemplate.ShowRowHeaderColumn = true; //the one on the child template can be true/false, it doesn't matter childGridViewTemplate.ShowRowHeaderColumn = false; testGridView.MasterTemplate.Templates.Add(childGridViewTemplate); GridViewRelation relation = new GridViewRelation(testGridView.MasterTemplate); relation.ChildTemplate = childGridViewTemplate; relation.RelationName = "ParentChildren"; relation.ParentColumnNames.Add("id"); relation.ChildColumnNames.Add("parent_id"); testGridView.Relations.Add(relation); LoadData(); } private void LoadData() { List<MyParentClass> myParentList = new List<MyParentClass>(); for(int i=1; i<=100; i++) { myParentList.Add(new MyParentClass() { id = i, name = i.ToString(), info = "blabla" }); } List<MyChildClass> myChildList = new List<MyChildClass>(); Random random = new Random(1); for(int i=1; i<=300; i++) { myChildList.Add(new MyChildClass() { parent_id = random.Next(1,100), id = i, name = i.ToString(), info = "blabla" }); } testGridView.DataSource = myParentList; childGridViewTemplate.DataSource = myChildList; } private GridViewTemplate childGridViewTemplate; } public class MyParentClass { public int id { get; set; } public String name { get; set; } public String info { get; set; } } public class MyChildClass { public int parent_id { get; set; } public int id { get; set; } public String name { get; set; } public String info { get; set; } }}namespace RadGridViewProblems{ partial class TestGridForm { /// <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.testGridView = new Telerik.WinControls.UI.RadGridView(); ((System.ComponentModel.ISupportInitialize)(this.testGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); this.SuspendLayout(); // // testGridView // this.testGridView.Dock = System.Windows.Forms.DockStyle.Fill; this.testGridView.Location = new System.Drawing.Point(0, 0); // // testGridView // this.testGridView.Name = "testGridView"; this.testGridView.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1); // // // this.testGridView.RootElement.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1); this.testGridView.Size = new System.Drawing.Size(833, 444); this.testGridView.TabIndex = 0; this.testGridView.Text = "radGridView1"; // // TestGridForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(833, 494); this.Controls.Add(this.testGridView); this.Name = "TestGridForm"; this.Padding = new System.Windows.Forms.Padding(0, 0, 0, 50); // // // this.RootElement.ApplyShapeToControl = true; this.Text = "Test Form"; ((System.ComponentModel.ISupportInitialize)(this.testGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); this.ResumeLayout(false); } #endregion private Telerik.WinControls.UI.RadGridView testGridView; }}using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Telerik.WinControls.UI;using Telerik.WinControls.Enumerations;namespace RadGridViewProblems{ /* * Demonstate a gridview problem when setting the datasource a second time (or more) when a child row is clicked * the grid scrolls to the bottom, reason/workaround: unknown */ public partial class TestGridForm2 : RadForm { public TestGridForm2() { InitializeComponent(); this.Load += new EventHandler(FormLoaded); } private void FormLoaded(object sender, EventArgs e) { //testGridView.ReadOnly = true; testGridView.AutoGenerateColumns = true; childGridViewTemplate = new GridViewTemplate(); childGridViewTemplate.AutoGenerateColumns = true; testGridView.MasterTemplate.ShowRowHeaderColumn = true; childGridViewTemplate.ShowRowHeaderColumn = false; testGridView.MasterTemplate.Templates.Add(childGridViewTemplate); GridViewRelation relation = new GridViewRelation(testGridView.MasterTemplate); relation.ChildTemplate = childGridViewTemplate; relation.RelationName = "ParentChildren"; relation.ParentColumnNames.Add("id"); relation.ChildColumnNames.Add("parent_id"); testGridView.Relations.Add(relation); LoadData(); } private void LoadData() { /*childGridViewTemplate.DataSource = null; testGridView.DataSource = null;*/ List<MyParentClass> myParentList = new List<MyParentClass>(); for(int i=1; i<=100; i++) { myParentList.Add(new MyParentClass() { id = i, name = i.ToString(), info = "blabla" }); } List<MyChildClass> myChildList = new List<MyChildClass>(); Random random = new Random(1); for(int i=1; i<=300; i++) { myChildList.Add(new MyChildClass() { parent_id = random.Next(1,100), id = i, name = i.ToString(), info = "blabla" }); } childGridViewTemplate.DataSource = myChildList; testGridView.DataSource = myParentList; } private void resetButton_Click(object sender, EventArgs e) { LoadData(); } private GridViewTemplate childGridViewTemplate; }}namespace RadGridViewProblems{ partial class TestGridForm2 { /// <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.testGridView = new Telerik.WinControls.UI.RadGridView(); this.resetButton = new Telerik.WinControls.UI.RadButton(); ((System.ComponentModel.ISupportInitialize)(this.testGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.resetButton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); this.SuspendLayout(); // // testGridView // this.testGridView.Dock = System.Windows.Forms.DockStyle.Fill; this.testGridView.Location = new System.Drawing.Point(0, 0); this.testGridView.Name = "testGridView"; this.testGridView.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1); // // // this.testGridView.RootElement.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1); this.testGridView.Size = new System.Drawing.Size(833, 444); this.testGridView.TabIndex = 0; this.testGridView.Text = "radGridView1"; // // resetButton // this.resetButton.Location = new System.Drawing.Point(90, 460); this.resetButton.Name = "resetButton"; this.resetButton.Size = new System.Drawing.Size(130, 24); this.resetButton.TabIndex = 1; this.resetButton.Text = "Reset datasources"; this.resetButton.Click += new System.EventHandler(this.resetButton_Click); // // TestGridForm2 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(833, 494); this.Controls.Add(this.resetButton); this.Controls.Add(this.testGridView); this.Name = "TestGridForm2"; this.Padding = new System.Windows.Forms.Padding(0, 0, 0, 50); // // // this.RootElement.ApplyShapeToControl = true; this.Text = "Test Form"; ((System.ComponentModel.ISupportInitialize)(this.testGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.resetButton)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); this.ResumeLayout(false); } #endregion private Telerik.WinControls.UI.RadGridView testGridView; private Telerik.WinControls.UI.RadButton resetButton; }}
