14 Answers, 1 is accepted
Could you explain a little more about your situation and what you would like to achieve?
Thanks
Richard
this is my problem :
When the radgrid is populated and the user changes a cell within a row, the row is not flagged as "modified" until the user actually clicks onto another location on the datagrid. If the user modifies any values in a row and immediately clicks the "Save" button on my winform, the row is not flagged as having been modified and is not showing up in my list of modified rows.
becuse of that i whan't to change to state ( but mybe it's not a good idea).
Thank u.
You can always call radGridView1.EndEdit() on the Save button click, then you will force a CellValueChanged / ValueChanged event to fire, (if the Save button is a command button on the grid) or it should fire automatically if the grid loses focus.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
I try the EndEdit but it doesn't work.
my save button is not place on the grid, he outside the grid and it save all the changes that the user made.
something impotent :
its happened just when the cell is Boolean !
When the cell is text it's work great.
Dror
On the row, if you call (for exmaple)
this.radGridView2.CurrentRow.InvalidateRow();this will force a CellFormatting and ValueFormatting event.
hope that helps
Richard
Please try the following example and let me know if this works for you:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Windows.Forms;using Telerik.WinControls.UI;public partial class Form1 : Form{ private RadGridView radGridView1; private List<GridViewRowInfo> modifiedRows = new List<GridViewRowInfo>(); public Form1() { InitializeComponent(); this.Controls.Add(radGridView1 = new RadGridView()); radGridView1.Size = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 24); radGridView1.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.CellValueChanged += new GridViewCellEventHandler(radGridView1_CellValueChanged); var saveButton = new RadButton(); saveButton.Text = "Save"; saveButton.Click += new EventHandler(saveButton_Click); saveButton.Dock = DockStyle.Bottom; this.Controls.Add(saveButton); } void saveButton_Click(object sender, EventArgs e) { if (this.radGridView1.IsInEditMode) { radGridView1.EndEdit(); } MessageBox.Show("Number of modified Rows: " + modifiedRows.Count.ToString()); modifiedRows.Clear(); } void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { modifiedRows.Add(e.Row); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); radGridView1.DataSource = new TestsCollection(10); }}public class TestTypes{ public int Id { get; set; } public bool ReadOnly { get; set; } public string Name { get; set; }}public class TestsCollection : BindingList<TestTypes>{ public TestsCollection(int noItems) { for (int i = 0; i < noItems; i++) { this.Add(new TestTypes { Id = i, ReadOnly = i % 2 == 0 ? true : false, Name = "Name" + i }); } }}Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Hi,
Maybe I doesn't explained myself very well.
The problem is that when the user change the value of cell with Boolean type the property "ismodified" doesn't change to true ! until the user don’t set focus to anther row.
Thank u for your patience.
We have introduced an issue in the latest version of RadGridView which is related to the fact that the state of the binding source is not modified when the current row of the control is modified by code. We will address it in a next release.
As a workaround, please use the CellValueChanged event of RadGridView to set the state of the modified item:
privatevoidradGridView1_CellValueChanged(objectsender, GridViewCellEventArgs e){if(e.Row ==this.radGridView1.CurrentRow){DataRow tableRow = (this.radGridView1.CurrentRow.DataBoundItemasDataRowView).Row;tableRow.SetModified();}}
Please let us know if this approach works in your case.
Best regards,
Alexander
the Telerik team