DataGrid Questions 
Author Message
 DataGrid Questions

Using VB...
I have a DataGrid bound to a DataSet (which has one parent table/1 child
table).

When a user expands the DataGrid child table with a mouse click, each time
the program starts a new sub, that child table collapses back to just a +
mark.  Each sub we are talking about does add new row to the DataSet, but I
don't know why it is doing the collapsing.  It would seem logical that
whatever state it was in (expanded) would be the state it would stay in
during the next sub.

- Why is the above collapsing the child table?

-At what point does the DataGrid automatically reflect changes made to the
DataSet?  Is it after Add Row or Is it after AddRow and AcceptChanges is
applied to the DataSet?  I don't think you need to call anything, such as
update, for the datagrid to display the new row.

Finally, I am (still) confused about TableStyles.

- in the DataGrid TableStyles Collection Editor, you can only have 1
TableStyles per table name (mapping name) (it will not let you create a 2nd
Style with the same table name), so I don't see how you can switch table
styles in code to display only a sub set (such as fewer columns).  Certainly
you can edit certain TableSytle characteristics in code, but not switch
TableStyles concerning the same table.

- if hou do edit characteristics as above, how do you reset them to the
original TableStyle characteristics?

- Also, if you have 2 TableStyles in your collection, I don't see how to
switch back and forth between them (i.e. make one active, then the other
active
later), with our going through the process of removing them all from the
collection and adding only the one you want to the collection, which is not
very intuitive.

Thanks!
Bob Day



Sun, 30 Jan 2005 02:16:23 GMT  
 DataGrid Questions
I believe that you can't set the MappingName of multiple tablestyle object
in the TableStyles collection to the same table. You can use a index
variable to remember the current active table style. And toggle the
corresponding tablestyle object's MappingName on and off like this:

        If lIdx = 0 Then
            DataGrid1.TableStyles(0).MappingName = vbNullString
            DataGrid1.TableStyles(1).MappingName =
DataSet11.Tables(0).TableName
            lIdx = 1
        Else
            DataGrid1.TableStyles(1).MappingName = vbNullString
            DataGrid1.TableStyles(0).MappingName =
DataSet11.Tables(0).TableName
            lIdx = 0
        End If

David Yuan
This posting is provided "AS IS" with no warranties, and confers no rights.
"Got .Net?  http://www.gotdotnet.com".  



Sun, 30 Jan 2005 17:23:13 GMT  
 DataGrid Questions

Thats the problem, you cannot assign two tablestyle objects to the same
table name (mapping name).  Under properties for the DataGrid, go into
the TableStyles collection, and if you enter a new TableStyle with a
TableName in use by an existing TableStyle, you get the following:
"Invalid: The data grid table styles collection already contains a table
style with the same mapping name.
Parameter name: table"

Based on your suggestion, I will try assinging no mapping name in the
editor, and assigning/unassigning it in code to change the current
TableStyle.

Even if that works, it doesn't make sense.  You don't activate a member
of a collection by changing a property (ie the Mapping Name).  If I want
the row collection, you would instantiate the DataRow and set it equal
to the member of the colleciton you want (i.e.
DataSet.Table.Row(index)).  It would seem that you should be able to
toggle the table style in a similar way, simply instantiating the
current table style = a different table style (and not changing
properties like mapping name), but I cannot see how to do that.

Bob Day

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 30 Jan 2005 21:45:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Datagrid questions when bound to datatable

2. about DataGrid question

3. DataGrid question

4. another datagrid question

5. datagrid question

6. DataGrid question

7. Datagrid question (probably an easy one)

8. Datagrid Question

9. datagrid questions.

10. ANOTHER DataGrid Question

11. listbox/datagrid questions!

12. DataGrid Question

 

 
Powered by phpBB® Forum Software