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.

Prevent EnableAddNew from expanding GridDataBroundGrid beyond a specific number of rows

Thread ID:

Created:

Updated:

Platform:

Replies:

93477 Mar 16,2010 10:09 AM Mar 16,2010 12:34 PM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 16, 2010 10:09 AM

Hello,

I'm working with a GridDataBoundGrid on a windows form, which has the "EnableAddNew" property set to true, so that the grid automatically expands 1 row at a time per the user's needs. However, I don't want the grid to expand beyond 8 rows and I'm finding the logic to be a bit tricky to prevent this. Currently I have code that looks like this:

void GridSubParts_CurrentCellEditingComplete(Object sender, EventArgs e)
{
GridDataBoundGrid grid = (GridDataBoundGrid)sender;
grid.EnableAddNew = grid.Model.RowCount <= 8 ? true : false;
}

The result is once the GridDataBoundGrid control reaches 8 rows, when you click several different cells (which clicking a given cell triggers the 'cell editing') the GridDataBoundGrid will expand to 9 rows and then shrink back to 8 rows every other click.

What is the preferred way of preventing the GridDataBoundGrid from expanding beyond a specific amount of rows? Is there a maximum rows property?



Clay Burch [Syncfusion]
Replied On March 16, 2010 12:34 PM

There is no maximum rows proeprty for a GridDataBoundGrid.

If your datasource is some kind of IBindingList or DataView that supports a ListChanged event, then you can use that event to set the EnableAddNew property in a timely fashion.


void _ListChanged(object sender, ListChangedEventArgs e)
{
IList list = sender as IList;
if (list.Count == 8)
{
gridDataBoundGrid1.EnableAddNew = false;
}
}

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.

;