|
-
Apr 2nd, 2008, 04:54 PM
#1
Thread Starter
Addicted Member
-
Apr 2nd, 2008, 06:42 PM
#2
Re: Dynamic DGV
I assume that the BindingSource is bound to a DataTable. Is that empty column in the DataTable or is it an unbound column in the grid only? This would be much easier if it was in the DataTable.
-
Apr 2nd, 2008, 06:50 PM
#3
Thread Starter
Addicted Member
-
Apr 2nd, 2008, 07:51 PM
#4
Re: Dynamic DGV
Even if it has nothing to do with the database you can still add the column to the DataTable. It's just that doing so makes everything much easier because the DataColumn can handle everything for you. Otherwise you'd have to handle events and perform the calculation yourself. It could look something like this:
vb.net Code:
Dim table As New DataTable adapter.Fill(table) table.Columns.Add("Column2", GetType(Integer), "Column1 + 10") grid.DataSource = table
That's all you have to do. The grid will create the display column automatically and the table will handle generating the values for the evaluated column. There's no issue when saving either because, unless you explicitly tell it to, there will be no attempt to save that column to the database.
-
Apr 3rd, 2008, 02:35 PM
#5
Thread Starter
Addicted Member
Re: Dynamic DGV
Code:
Unable to cast object of type 'System.Data.DataTable' to type 'oft_produseDataTable'.
???
I'm still learning VB.NET
Sorry for my bad english
Thanks for your help
-
Apr 3rd, 2008, 05:15 PM
#6
Re: Dynamic DGV
So you're using a typed DataSet, with typed DataTables and TableAdapters instead of DataAdapters. You have to create an instance of your typed oft_produseDataTable class instead of the standard DataTable class. I've never tried but I don't see why you wouldn't be able to add a new column to it still. It is derived from DataTable so it's still got all the members a DataTable has.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|