By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Setting Limitation to number of Rows in DataGrid?

P: n/a
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
May 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
fixed it....

Table.DefaultView.AllowNew = False

Have fun/
Lars

"Lars Netzel" <ui****@adf.se> wrote in message
news:OJ**************@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

May 15 '06 #2

P: n/a
Lars,

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

http://www.syncfusion.com/FAQ/Window...44c.aspx#q653q

Kerry Moorman
"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

May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.