Ok
I have a simple but annoying problem.
A datatable bound to a radgridview and 1 column is checkboxcolumn. If user clicks the checkboxcolumn, cell goes to edit mode bot not changed the value on the datatable. After press enter button or selecting a different row value changes on datasource.
so I wrote a code for close editor on value changed
I have a simple but annoying problem.
A datatable bound to a radgridview and 1 column is checkboxcolumn. If user clicks the checkboxcolumn, cell goes to edit mode bot not changed the value on the datatable. After press enter button or selecting a different row value changes on datasource.
so I wrote a code for close editor on value changed
private void RouteGrid_ValueChanged(object sender, EventArgs e)
{
RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
if (editor != null)
{
(editor.EditorManager as GridViewEditManager).CloseEditor();
}
}
But my problem is if i want to change the source all values on the grid changes except selected row or current row. I changed all the property of the rows and cells property (IsSelected,IsCurrent...) but value never changes.
Here is my code
But after this selected cell value doesnt change.
Is this a bug or is there anything wrong in my code?
}
But my problem is if i want to change the source all values on the grid changes except selected row or current row. I changed all the property of the rows and cells property (IsSelected,IsCurrent...) but value never changes.
Here is my code
private void btnCancelChanges_Click(object sender, EventArgs e) { RouteGrid1.CurrentRow = null; RouteGrid1.Enabled = false; if (MessageBox.Show("...", "...", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { DataRow[] Result = null; this.Cursor = Cursors.WaitCursor; foreach (DataTable routeTable in viewSalesmanInfo.RouteTableCollection) { if (routeTable != null && routeTable.Rows.Count > 0 && !String.IsNullOrEmpty(routeTable.TableName)) { Result = routeTable.Select("m_Current_State_Id = 0 AND Current_State_Id = -1"); if (Result != null && Result.Length > 0) foreach (DataRow addCustomer in Result) routeTable.Rows.Remove(addCustomer); Result = routeTable.Select( "(OrderRoute <> m_OrderRoute Or " + "PaymentRoute <> m_PaymentRoute Or " + "DeliveryRoute <> m_DeliveryRoute Or " + "MergeRoute <> m_MergeRoute Or " + "Route_Position <> m_Route_Position)" + " OR m_Current_State_Id <> Current_State_Id"); if (Result != null && Result.Length > 0) foreach (DataRow updateCustomer in Result) { updateCustomer.BeginEdit(); updateCustomer["Current_State_Id"] = updateCustomer["m_Current_State_Id"]; updateCustomer["Route_Position"] = updateCustomer["m_Route_Position"]; updateCustomer["MergeRoute"] = updateCustomer["m_MergeRoute"]; updateCustomer["OrderRoute"] = updateCustomer["m_OrderRoute"]; updateCustomer["PaymentRoute"] = updateCustomer["m_PaymentRoute"]; updateCustomer["DeliveryRoute"] = updateCustomer["m_DeliveryRoute"]; updateCustomer.EndEdit(); } } } this.Cursor = Cursors.Default; this.RouteGrid1.MasterTemplate.Refresh(); RouteGrid1.Enabled = true; } }But after this selected cell value doesnt change.
Is this a bug or is there anything wrong in my code?
4 Answers, 1 is accepted
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Sep 2010, 04:43 PM
Hello Umut,
Try changing that a little with this and let me know if it helped:
Try changing that a little with this and let me know if it helped:
private void btnCancelChanges_Click(object sender, EventArgs e) { RouteGrid1.ClearSelection(); RouteGrid1.CurrentRow = null; RouteGrid1.Enabled = false; if (MessageBox.Show("...", "...", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { DataRow[] Result = null; this.Cursor = Cursors.WaitCursor; foreach (DataTable routeTable in viewSalesmanInfo.RouteTableCollection) { if (routeTable != null && routeTable.Rows.Count > 0 && !String.IsNullOrEmpty(routeTable.TableName)) { Result = routeTable.Select("m_Current_State_Id = 0 AND Current_State_Id = -1"); if (Result != null && Result.Length > 0) foreach (DataRow addCustomer in Result) routeTable.Rows.Remove(addCustomer); Result = routeTable.Select( "(OrderRoute <> m_OrderRoute Or " + "PaymentRoute <> m_PaymentRoute Or " + "DeliveryRoute <> m_DeliveryRoute Or " + "MergeRoute <> m_MergeRoute Or " + "Route_Position <> m_Route_Position)" + " OR m_Current_State_Id <> Current_State_Id"); if (Result != null && Result.Length > 0) foreach (DataRow updateCustomer in Result) { updateCustomer.BeginEdit(); updateCustomer["Current_State_Id"] = updateCustomer["m_Current_State_Id"]; updateCustomer["Route_Position"] = updateCustomer["m_Route_Position"]; updateCustomer["MergeRoute"] = updateCustomer["m_MergeRoute"]; updateCustomer["OrderRoute"] = updateCustomer["m_OrderRoute"]; updateCustomer["PaymentRoute"] = updateCustomer["m_PaymentRoute"]; updateCustomer["DeliveryRoute"] = updateCustomer["m_DeliveryRoute"]; updateCustomer.EndEdit(); } } } this.Cursor = Cursors.Default; this.RouteGrid1.Refresh(); RouteGrid1.Enabled = true; } }0
Umut
Top achievements
Rank 1
answered on 29 Sep 2010, 06:35 PM
Still same...
There is no problem with datasource but only selected or current column cell values still old values. i changed the cells IsCurrent and IsSelected property to false but still same.
İs this a bug?
There is no problem with datasource but only selected or current column cell values still old values. i changed the cells IsCurrent and IsSelected property to false but still same.
İs this a bug?
0
Umut
Top achievements
Rank 1
answered on 01 Oct 2010, 11:59 AM
Is there any progress?
0
Emanuel Varga
Top achievements
Rank 1
answered on 01 Oct 2010, 12:30 PM
Hello again Umut,
I have created an example using a datatable that works as expected in my version Q2 2010 SP2, can you please try it and tell me what's different in your scenario?
Please try this out, and let me know if you have the same problem with this.
Best Regards,
Emanuel Varga
I have created an example using a datatable that works as expected in my version Q2 2010 SP2, can you please try it and tell me what's different in your scenario?
using System;using System.Data;using System.Drawing;using System.Windows.Forms;using Telerik.WinControls.UI;public partial class Form1 : Form{ RadGridView radGridView1; public Form1() { InitializeComponent(); this.Size = new Size(500, 300); this.Load += new EventHandler(Form1_Load); } void Form1_Load(object sender, EventArgs e) { radGridView1 = new RadGridView(); radGridView1.Size = new Size(500, this.Height - 86); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; this.Controls.Add(radGridView1); radGridView1.DataSource = CreateDataTable(); var makeDirtyButton = new RadButton(); makeDirtyButton.Click += new EventHandler(makeDirtyButton_Click); makeDirtyButton.Text = "Make all data dirty..."; makeDirtyButton.Dock = DockStyle.Bottom; this.Controls.Add(makeDirtyButton); var refreshDataButton = new RadButton(); refreshDataButton.Text = "Refresh all data"; refreshDataButton.Dock = DockStyle.Bottom; refreshDataButton.Click += new EventHandler(refreshDataButton_Click); this.Controls.Add(refreshDataButton); } void refreshDataButton_Click(object sender, EventArgs e) { RefreshDataTable((DataTable)radGridView1.DataSource); } void makeDirtyButton_Click(object sender, EventArgs e) { var table = (DataTable)radGridView1.DataSource; foreach (DataRow row in table.Rows) { row[1] = row[1] + "Dirty"; } } private DataTable CreateDataTable() { DataTable table = new DataTable(); table.Columns.Add("Id", typeof(int)); table.Columns.Add("Name", typeof(string)); table.Rows.Add(1, "Name1"); table.Rows.Add(2, "Name2"); return table; } private void RefreshDataTable(DataTable table) { int count = 1; foreach (DataRow row in table.Rows) { row[0] = count; row[1] = "Name" + count++; } }}Please try this out, and let me know if you have the same problem with this.
Best Regards,
Emanuel Varga