|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Setting Limitation to number of Rows in DataGrid?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 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 > 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 > > >
Storing collection of one class inside another
Session variable as string (array) Server calls client behind firewall/NAT convert byte() in ASCII code to letters? Need one Regular Expression word automation bookmarks Access MDI child properties generically Raise Maximum Compiler Error Limit? Hide an application to taskbar by the clock Datagridview and ComboBoxColumn |
|||||||||||||||||||||||