jplocster Posted March 21, 2003 Posted March 21, 2003 I am using VB.Net and have a very simple form which contains a DataGrid and a few buttons. I want the user to be able to edit the cells in the datagrid but I do not want the user to be able to add new rows by using the "*" row at the bottom of the grid. I would like this "*" row to not exist. I have found the dataview property called AllowNew but no matter how I set this field (true of false) the "*" row always appears and new rows can be added. I must be binding something wrong. I would like some help getting this functionality working correctly Thank you. Here is the basic outline of my code right now: Create a Datagrid. Add the DataGrid control to my form. Create a DataSet Create Tables Add the Tables to the DataSet Add Columns to the Tables Bind the DataSet to the DataGrid then Dim myDV As DataView myDV.Table = ds_ClassRoom.Tables(CLASSROOM_TABLE) myDV.AllowNew = False myDV.AllowDelete = False Quote
Moderators Robby Posted March 21, 2003 Moderators Posted March 21, 2003 you may need to use the DataTable... myDV = New DataView(myDT) myDV.AllowNew = False myDV.AllowDelete = False myDV.AllowEdit = True Quote Visit...Bassic Software
jplocster Posted March 21, 2003 Author Posted March 21, 2003 I have tried it both ways, no difference. Any other thoughts? Quote
jplocster Posted March 21, 2003 Author Posted March 21, 2003 I found this fix on another forum somewhere (I don't understand why I should be required to use the CurrencyManager to do this but it does yield the desired results): Dim cm As CurrencyManager Dim dv As DataView cm = CType(Me.BindingContext(ds_ClassRoom, CLASSROOM_TABLE), CurrencyManager) dv = CType(cm.List, DataView) dv.AllowNew = False dv.AllowDelete = False dv.AllowEdit = True Where ds_ClassRoom is a DataSet and CLASSROOM_TABLE is a string which holds the name of the table I have bound the datagrid to. Me is the parent form of the DataGrid I think. At least thats what it is on my proggy. Hope this helps anybody else with the same problem. If anyone knows why the Currency manager has to get involved I would love to hear the explanation. It seems like a hack that was needed because of a feature that was left out. Quote
Moderators Robby Posted March 21, 2003 Moderators Posted March 21, 2003 You really don't need the CurrencyMAnager with a Datagrid. Post all your relevant code and we'll figure it out. Quote Visit...Bassic Software
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.