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.
Syncfusion Feedback

GridAddNewRecord in GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

46347 Jul 11,2006 04:56 PM UTC Jul 12,2006 10:43 AM UTC Windows Forms 4
loading
Tags: GridControl
Kai Abesser
Asked On July 11, 2006 04:56 PM UTC

Dear all, how can i add a new row via a button click (grid is set to readonly !) ? Thanks Kai

Administrator [Syncfusion]
Replied On July 11, 2006 05:33 PM UTC

Hi Kai, Try this code to add a new record in a grid. Here is a code snippet. DataTable dt = this.gridGroupingControl1.DataSource as DataTable; this.gridGroupingControl1.BeginUpdate(); DataRow dr = dt.NewRow(); dt.Rows.Add(new object[]{}); dt.AcceptChanges(); this.gridGroupingControl1.EndUpdate(true); Let me know if this helps. Best Regards, Haneef

Kai Abesser
Replied On July 11, 2006 07:21 PM UTC

Dear Haneef, i work with typed datasets, i.e.: this.analyseGrid.BeginUpdate(); dsXLAuftragAnalyseView.XLAuftragMethodeDataTable dt = this.analyseGrid.DataSource as dsXLAuftragAnalyseView.XLAuftragMethodeDataTable; dsXLAuftragAnalyseView.XLAuftragMethodeRow row = dt.NewXLAuftragMethodeRow(); row.fIsAktiv = true; ... this.dsXLAuftragAnalyseView.XLAuftragMethode.AddXLAuftragMethodeRow(row); this.xlAuftragMethodeTableAdapter.Update(this.dsXLAuftragAnalyseView); this.dsXLAuftragAnalyseView.AcceptChanges(); this.analyseGrid.EndUpdate(true); but i get an exception, that dt is null. when i add the row direct in my dataset, anything works, but the grid dosen´t reflect the new record ... regards kai

Administrator [Syncfusion]
Replied On July 11, 2006 09:49 PM UTC

Hi Kai, Try this code snippet to add a record through grouping table. Please find the code snippet below. //Form''s Load event this.gridGroupingControl1.NestedTableGroupOptions.ShowAddNewRecordBeforeDetails = true; this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = true; //button''s click event GridTable table = this.gridGroupingControl1.GetTable("YourTableName"); table.BeginEdit(); Record r = null; foreach(Element el in table.DisplayElements) { if( el.Kind == DisplayElementKind.AddNewRecord ) { r = el.ParentRecord; r.SetCurrent(); if( r != null) { if (r.IsCurrent) { r.BeginEdit(); if (r.IsEditing) { r.SetValue("YourColumnName", "BX"); r.SetValue("YourColName", "ID"); r.EndEdit(); } } } break; } } table.EndEdit(); Let me know if this helps. Best Regards, Haneef

Kai Abesser
Replied On July 12, 2006 10:43 AM UTC

Hi Haneef, intressting way ... thanks it works ... regards Kai

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.

Warning Icon 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.Close Icon

;