The One Who Was Posted April 14, 2004 Posted April 14, 2004 Greetings: I was curious if anyone knew of a way to make a data table prevent adding/deleting records using a dataview?? The reason I ask is that the demo of some datagrid column styles I'm considering purchasing doesn't seem to like it when I try using a dataview instead of a data table. http://www.rustemsoft.com/dgcolumns.htm Quote ~~ The One Who Was ~~
Moderators Robby Posted April 14, 2004 Moderators Posted April 14, 2004 They must have a ReadOnly property. ?? Quote Visit...Bassic Software
The One Who Was Posted April 15, 2004 Author Posted April 15, 2004 I'd like for the user to have the ability to make changes to the datagrid, just not allow add/delete rows in the datatable. (not exactly read only) My apologies for not explaining myself that well. I can work around this so that the newly add/deleted valules aren't applied to the database, but seems somewhat like a sloppy method. I should likely reconsider having separate add/delete forms for this particular section of my application. However, if anyone knows of a way or has a suggestion on how I may accomplish what I'm trying to do with a datatable I'd really like to hear it :D Quote ~~ The One Who Was ~~
AlexCode Posted April 15, 2004 Posted April 15, 2004 You can allways declare the datarow 'WithEvents' and grab the 'RowChanging' event of it... there you can: Private Sub dt_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles dt.RowChanging If e.Action = DataRowAction.Add Then 'Validate whatever you want... End If End Sub Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
JABE Posted April 15, 2004 Posted April 15, 2004 Bind the grid to a dataview. Set AllowAdd and AllowDelete of the dataview to False. Quote
Moderators Robby Posted April 15, 2004 Moderators Posted April 15, 2004 JABE, the problem is that he said the datgrid doesn't take kindly to Dataviews, I'm not really sure why though. :( Quote Visit...Bassic Software
AlexCode Posted April 15, 2004 Posted April 15, 2004 (edited) As he's using some 3rd party column styles dor the datagrid they (the columns) must be somehow confused with the header names... who know what kind of code is behind those "custom columns"?? Wouldn't it be sheaper to buy a whole new grid component? Even if not I think it would allways be better, the diference can't be so big... http://www.devexpress.com ... XtraGrid component... rulezzzz Alex :p Edited April 16, 2004 by AlexCode Quote Software bugs are impossible to detect by anybody except the end user.
The One Who Was Posted April 15, 2004 Author Posted April 15, 2004 Yeah, it's really wierd that these column styles would prevent me from using a dataview =/ Thanks for the tip on the datagrid Alex. I'll check it out. I was looking at one from syncfusion, but it was rather pricey for the amount I'll be using it. Quote ~~ The One Who Was ~~
AlexCode Posted April 15, 2004 Posted April 15, 2004 I've tryed almost every grid component... XtraGrid won... no doubt about it... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Moderators Robby Posted April 15, 2004 Moderators Posted April 15, 2004 I sampled the one that Alex recommended and it is a pretty neat grid. Quote Visit...Bassic Software
The One Who Was Posted April 16, 2004 Author Posted April 16, 2004 Thanks for the tips. I must agree, the demo seems great =) and not insanely priced :D and for anyone who may be having a problem with the link... http://www.devexpress.com Thanks again for all the replies. I greatly appreciate it! Quote ~~ The One Who Was ~~
AlexCode Posted April 16, 2004 Posted April 16, 2004 I'm sorry about the link error... :( I use almost all DevExpress .net controls and they're all great and on top of this, the support repplyes to in 24hours max... Alex :P Quote Software bugs are impossible to detect by anybody except the end user.
JABE Posted April 16, 2004 Posted April 16, 2004 JABE' date=' the problem is that he said the datgrid doesn't take kindly to Dataviews, I'm not really sure why though. :([/quote'] Oh, I guess I was thrown off by his initial question: I was curious if anyone knew of a way to make a data table prevent adding/deleting records using a dataview?? Anyway, if the datagrid is bound to a datatable instead, it's just a matter of getting to the DefaultView of the datatable: CType(theDataGrid.DataSource, DataTable).DefaultView.AllowDelete = False CType(theDataGrid.DataSource, DataTable).DefaultView.AllowNew = False Quote
The One Who Was Posted April 16, 2004 Author Posted April 16, 2004 Oh, I guess I was thrown off by his initial question: Anyway, if the datagrid is bound to a datatable instead, it's just a matter of getting to the DefaultView of the datatable: CType(theDataGrid.DataSource, DataTable).DefaultView.AllowDelete = False CType(theDataGrid.DataSource, DataTable).DefaultView.AllowNew = False LOL Aye. that would do it. I'm sorry about Jabe. Thanks for the reply. I'll try that out. May save me some money... and then I can buy that other grid control after I pay my income tax! :D Quote ~~ The One Who Was ~~
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.