Home All Groups Group Topic Archive Search About

Setting Limitation to number of Rows in DataGrid?

Author
15 May 2006 10:31 AM
Lars Netzel
Hi

I need to have a limitation for the number of rows one can add in a datagrid
(bound from a DataTable), in this case maximum should be 10 rows.

My approach I guess is to catch the rownumber in the CurrencyManager via
BindingContext.PositionChanged but how do I then stop new rows from being
created?

in FormLoad() I add a handler for the bindingcontext and a datatable called
"Articles"
AddHandler BindingContext(Me.Articles).PositionChanged, AddressOf
ArticleList_PositionChanged

----------------------------------------------

Public Sub ArticleList_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

CurrencyManager).Position + 1

If CType(sender, CurrencyManager).Count > 10 Then

    'some smart code goes here?

End If

End Sub


Please Help!
/Lars Netzel

Author
15 May 2006 11:29 AM
Lars Netzel
fixed it....

Table.DefaultView.AllowNew = False

Have fun/
Lars



Show quoteHide quote
"Lars Netzel" <uih***@adf.se> wrote in message
news:OJQlmqAeGHA.2068@TK2MSFTNGP02.phx.gbl...
> Hi
>
> I need to have a limitation for the number of rows one can add in a
> datagrid (bound from a DataTable), in this case maximum should be 10 rows.
>
> My approach I guess is to catch the rownumber in the CurrencyManager via
> BindingContext.PositionChanged but how do I then stop new rows from being
> created?
>
> in FormLoad() I add a handler for the bindingcontext and a datatable
> called "Articles"
> AddHandler BindingContext(Me.Articles).PositionChanged, AddressOf
> ArticleList_PositionChanged
>
> ----------------------------------------------
>
> Public Sub ArticleList_PositionChanged(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> CurrencyManager).Position + 1
>
> If CType(sender, CurrencyManager).Count > 10 Then
>
>    'some smart code goes here?
>
> End If
>
> End Sub
>
>
> Please Help!
> /Lars Netzel
>
Author
15 May 2006 11:32 AM
Kerry Moorman
Lars,

Once 10 new rows have been added you could prevent the datagrid from
displaying its Append row:

http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q653q

Kerry Moorman


Show quoteHide quote
"Lars Netzel" wrote:

> Hi
>
> I need to have a limitation for the number of rows one can add in a datagrid
> (bound from a DataTable), in this case maximum should be 10 rows.
>
> My approach I guess is to catch the rownumber in the CurrencyManager via
> BindingContext.PositionChanged but how do I then stop new rows from being
> created?
>
> in FormLoad() I add a handler for the bindingcontext and a datatable called
> "Articles"
> AddHandler BindingContext(Me.Articles).PositionChanged, AddressOf
> ArticleList_PositionChanged
>
> ----------------------------------------------
>
> Public Sub ArticleList_PositionChanged(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> CurrencyManager).Position + 1
>
> If CType(sender, CurrencyManager).Count > 10 Then
>
>     'some smart code goes here?
>
> End If
>
> End Sub
>
>
> Please Help!
> /Lars Netzel
>
>
>