We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

No subject

Thread ID:

Created:

Updated:

Platform:

Replies:

3518 Mar 26,2003 01:21 PM Mar 26,2003 06:00 PM Windows Forms 1
loading
Tags: GridControl
Andy Ullman
Asked On March 26, 2003 01:21 PM

I want to use the rowheader area of a databound grid to indicate rows that have been modified and rows that are new (inserted). The code below works great for the modified rows, but with new rows (inserted via the asterisk on the grid navigation control) I get some weird display artifacts (new row flickering on/off as the datagrid is scrolled). Also, if I insert a new row into the datatable by calling InsertAt and operating directly on the datatable, the rowheader displays "New" where the new row -should- appear, but the new, blank row appears at the bottom of the datagrid. This code is from a control that inherits from GridDataBoundGrid: protected override void OnPrepareViewStyleInfo(Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { base.OnPrepareViewStyleInfo(e); if(e.ColIndex == 0 && e.RowIndex > 0) { int position = Binder.RowIndexToPosition(e.RowIndex); e.Style.CellType = "Header"; if ((DataSource as DataSet).Tables[DataMember].Rows[position].RowState == DataRowState.Modified) { e.Style.Text = "Mod"; e.Style.BackColor = Color.Red; } else if ((DataSource as DataSet).Tables[DataMember].Rows[position].RowState == DataRowState.Added) { e.Style.Text = "New"; e.Style.BackColor = Color.LightGreen; } } } Thanks Andy

Administrator [Syncfusion]
Replied On March 26, 2003 06:00 PM

If you use this code, you will get the inserted row displayed in the correct position.
private void button1_Click(object sender, System.EventArgs e)
{
	this.gridDataBoundGrid1.BeginUpdate();
	DataRow dr = dt.NewRow();
	dr[0] = "XXXXX";  //dt is the datatable
	dt.Rows.InsertAt(dr,2);
	dt.AcceptChanges();
			this.gridDataBoundGrid1.EndUpdate();
	this.gridDataBoundGrid1.Refresh();
}
BUT, this will not show your red new row tag because of the dt.AcceptChanges call. But without this call, the new datarow is not position so the grid can see it properly located in the data source. Maybe you can use some other marker to get the red row flags. Maybe save a list of them or something.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;