I am having a problem with the RadGridView not allowing the user to re-order the columns via column header dragging after the grid has been bound to a data source. I can click and begin to drag a column header, however once I release the mouse button, the column returns to its original position, not the position I dropped it at. This only happens after I have bound the grid to a datasource.
Am I doing something wrong or is this expected behavior?
Using GridView version 2009.2.9.729
The code below is a form with a RadGridView and 3 columns. After I click the bind button, I can no longer re-order columns:
Am I doing something wrong or is this expected behavior?
Using GridView version 2009.2.9.729
The code below is a form with a RadGridView and 3 columns. After I click the bind button, I can no longer re-order columns:
| using System; |
| using System.Drawing; |
| using System.Windows.Forms; |
| using System.ComponentModel; |
| using Telerik.WinControls.UI; |
| namespace TelerikGridTest |
| { |
| public partial class SimpleGridTest : Form |
| { |
| private Telerik.WinControls.UI.RadGridView radGridView1; |
| private void btnBind_Click(object sender, EventArgs e) |
| { |
| BindingList<SomeObject> data = new BindingList<SomeObject>(); |
| data.Add(new SomeObject("1.1", "1.2", "1.3", "1.4")); |
| data.Add(new SomeObject("2.1", "2.2", "2.3", "2.4")); |
| data.Add(new SomeObject("3.1", "3.2", "3.3", "3.4")); |
| radGridView1.DataSource = data; |
| //now I can't re-order columns |
| } |
| private void btnUnbind_Click(object sender, EventArgs e) |
| { |
| radGridView1.DataSource = null; |
| } |
| public SimpleGridTest() |
| { |
| GridViewTextBoxColumn gridViewTextBoxColumn1 = new GridViewTextBoxColumn(); |
| GridViewTextBoxColumn gridViewTextBoxColumn2 = new GridViewTextBoxColumn(); |
| GridViewTextBoxColumn gridViewTextBoxColumn3 = new GridViewTextBoxColumn(); |
| this.radGridView1 = new Telerik.WinControls.UI.RadGridView(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).BeginInit(); |
| this.SuspendLayout(); |
| this.radGridView1.Location = new System.Drawing.Point(15, 50); |
| gridViewTextBoxColumn1.FieldAlias = "Val1"; |
| gridViewTextBoxColumn1.FieldName = "Val1"; |
| gridViewTextBoxColumn1.HeaderText = "column1"; |
| gridViewTextBoxColumn1.UniqueName = "column1"; |
| gridViewTextBoxColumn1.Width = 150; |
| gridViewTextBoxColumn2.FieldAlias = "Val2"; |
| gridViewTextBoxColumn2.FieldName = "Val2"; |
| gridViewTextBoxColumn2.HeaderText = "column2"; |
| gridViewTextBoxColumn2.UniqueName = "column2"; |
| gridViewTextBoxColumn2.Width = 150; |
| gridViewTextBoxColumn3.FieldAlias = "Val3"; |
| gridViewTextBoxColumn3.FieldName = "Val3"; |
| gridViewTextBoxColumn3.HeaderText = "column3"; |
| gridViewTextBoxColumn3.UniqueName = "column3"; |
| gridViewTextBoxColumn3.Width = 150; |
| this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn1); |
| this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn2); |
| this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn3); |
| this.radGridView1.Name = "radGridView1"; |
| this.radGridView1.Size = new System.Drawing.Size(600, 355); |
| Button btnBind = new Button(); |
| btnBind.Text = "Bind to Data"; |
| btnBind.Location = new Point(15, 15); |
| btnBind.Size = new Size(100, 25); |
| btnBind.Click += btnBind_Click; |
| this.Controls.Add(btnBind); |
| Button btnUnbind = new Button(); |
| btnUnbind.Text = "Unbind from Data"; |
| btnUnbind.Location = new Point(115, 15); |
| btnUnbind.Size = new Size(100, 25); |
| btnUnbind.Click += btnUnbind_Click; |
| this.Controls.Add(btnUnbind); |
| this.ClientSize = new System.Drawing.Size(630, 415); |
| this.Controls.Add(this.radGridView1); |
| this.Name = "SimpleGridTest"; |
| this.Text = "SimpleGridTest"; |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).EndInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit(); |
| this.ResumeLayout(false); |
| this.PerformLayout(); |
| } |
| } |
| public class SomeObject |
| { |
| public SomeObject() { } |
| public SomeObject(string val1, string val2, string val3, string val4) |
| { |
| Val1 = val1; |
| Val2 = val2; |
| Val3 = val3; |
| Val4 = val4; |
| } |
| public string Val1 { get; set; } |
| public string Val2 { get; set; } |
| public string Val3 { get; set; } |
| public string Val4 { get; set; } |
| } |
| } |