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

opening grid to new record

Thread ID:

Created:

Updated:

Platform:

Replies:

11294 Mar 2,2004 03:18 AM UTC Mar 2,2004 04:20 PM UTC Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 2, 2004 03:18 AM UTC

Hi, How can I open a child grid to just show a new record? I don''t want to use a rowfilter Thanks

Administrator [Syncfusion]
Replied On March 2, 2004 07:36 AM UTC

I think you would have to the childGrid.DataSource to an empty DataTable that allows an AddNew. If you are using 2.0.2.1 code, then you should set this.gridDataBoundGrid1.Binder.OptimizeListChangedEvent = true; If you are using 1.6.1.8, then you will have to handle CurrentCellStartEditing, and explicitly add a DataRow to your DataTable at that point.
private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.RowIndex == this.gridDataBoundGrid1.Model.RowCount)
	{
		DataRow dr = this.dt.NewRow();
		dt.Rows.Add(dr);
	}
}

Administrator [Syncfusion]
Replied On March 2, 2004 12:44 PM UTC

Hi, Related to this: I get an error ''there is no row at position 1" when I try to set a rowfilter and the child grid contains no rows that satisfy the filter. Shouldn''t an empty grid just drop down?my code is. : Private Sub phraseGrid1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs) Handles phraseGrid1.CurrentCellShowingDropDown Dim width As Integer Dim height As Integer Dim dv As DataView Dim dt As DataTable Dim s As String Dim i As Integer Dim cc As GridCurrentCell = Me.phraseGrid1.CurrentCell iPhraseID = phraseGrid1.Model(cc.RowIndex, (cc.ColIndex + 7)).Text dv = Nothing dt = Nothing s = "" i = 0 If (cc.ColIndex = 1) Then Me.correctionGrid3.CurrentCell.EndEdit() Me.correctionGrid3.Binder.EndEdit() Dim bRecords As Boolean bRecords = False Me.correctionGrid3.AllowResizeToFit = False dt = Me.correctionGrid3.DataSource dt.Columns("phrase_id").DefaultValue = Me.phraseGrid1.Model(cc.RowIndex, (cc.ColIndex + 7)).Text dv = dt.DefaultView s = System.String.Format("Phrase_Id = ''{0}''", Me.phraseGrid1.Model(cc.RowIndex, (cc.ColIndex + 7)).Text) dv.RowFilter = s ElseIf (cc.ColIndex = 2) Then Me.elementGrid2.AllowResizeToFit = False dt = Me.elementGrid2.DataSource dv = dt.DefaultView s = System.String.Format("Phrase_Id = ''{0}''", Me.phraseGrid1.Model(cc.RowIndex, (cc.ColIndex + 6)).Text) dv.RowFilter = s End If End Sub >I think you would have to the childGrid.DataSource to an empty DataTable that allows an AddNew. > >If you are using 2.0.2.1 code, then you should set > > this.gridDataBoundGrid1.Binder.OptimizeListChangedEvent = true; > > >If you are using 1.6.1.8, then you will have to handle CurrentCellStartEditing, and explicitly add a DataRow to your DataTable at that point. >
>private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)
>{
>	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
>	if(cc.RowIndex == this.gridDataBoundGrid1.Model.RowCount)
>	{
>		DataRow dr = this.dt.NewRow();
>		dt.Rows.Add(dr);
>	}
>}

Administrator [Syncfusion]
Replied On March 2, 2004 12:46 PM UTC

The error message is ''there is no row at position 0'' rather than ''there is no row at position 1"

Administrator [Syncfusion]
Replied On March 2, 2004 04:20 PM UTC

To handle this problem, I think you will have to use the this.gridDataBoundGrid1.Binder.OptimizeListChangedEvent = true; setting which requires 2.0.x.

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

;