DataGrid questions

  • Thread starter Thread starter Bob Day
  • Start date Start date
B

Bob Day

using VS 2003, Vb.net...

In a WinForm, I have a datagrid with a parent child relationship named
"Display Details". When you click on the + next to the Parent row, below it
you get "Display Details" -
when you click on that, you get the related child rows of the Parent row.
Everything
displays correctly.

The parent row represents a telephone line (1,2,3 etc) and the child row
represents what is happening real time on that line (Parent Line 1, Child
Row 1 - Playing Greeting, etc.). So rows are constantly being added to the
child rows (i.e. the dataset) (whether displayed or not).

Question 1 - The "Display Details" seems non-standard windows programming.
When you click a + next to an item, you expect to expand what ever is under
it. Is there any way to get rid of the "Display Details" and just
automatically expand to the child rows? There is only this one relation in
the collection.

Question 2 - I would expect "if mygrid.isexpanded(0) = true" to tell me that
the datagrid for row 0 is expanded and the child rows are displayed. It
does not.
It only tells me that "Display Details" is visible or not. Toggling
mygrid.expanded and mygrid.collapsed. simply displays or doesn't display the
"Display Details" option. This is pretty useless. How can I determine if a
Parent row is displaying the child rows or not?

Question 3 - With a Parent row expanded to display child rows, how do I
modify the Parent row? You would think that simply modifying the
corresponding DataSet column value would accomplish this, but this generates
an error that I cannot make sense out of. How do you update a Parent Row
while it is expanded shows related child rows?

Question 4 - Updating a Parent row column value(not a column used in
creating the parent/child relationship) seems to always collapse the child
rows for that parent row. Is there a way around this?

Question 5 - Adding child rows to the DataSet does not display them in the
datagrid if the screen is already full with previously child rows. You can,
of course, scroll down to see it. How would you make the last child row
added visible?

Thanks for your help.
Bob
 
Hello Bob,
Do you mean the effect like this?

+ LineNo LineDescription
| 1 a Line
--StatusNo Status
1 Playing
2 Idle

To implement this effect, I think you need an event like
OnTreeNodeExpanding and some methods to create the child datagrid by
yourself.
Unfortunately, the Datagrid component neither had a property to change
the behavior of the tree node, nor offered a method/event to override it. it
may not be possible to implement this effect.

Regards,
Ying Shen Yu
Microsoft Partner Online Support
This posting is provided "AS IS" with no warranties, and confers no rights.
 
No, it would look like this:
+ LineNo LineSummary
1 Play Message
-----------------------------------
Now click the + button, and you get:
- LineNo LineSummary
| 1 Play Message
|------> Display Details (which is underlined)
----------------------------------------------
Now click Display Details and you get the details
Line No Summary Detail
1 Play Message File Name: Greeting.wave
-----------------------------------------------

As far as I can see, this is a very straight forward use of a datagrid and
Parent/Child relationships, so I don't understand why the commands
surrounding it aren't ituitieve (i.e. my original questions about above).

Any help would be appreciated.

Thanks!
Bob Day
 
Hello Bob,
I'm afraid I'm not quite clear about your description. Let me repeat it,

You have two tables in a dataset schema, and there a relation between
the two tables, the datagrid displays the master
table at first, then if you click the '+' next to the item, the grid will
show you the relation name, and if you click
on the relation name, the (whole) grid will navigate to the child
table(ofcourse showing the records related
to the master record only).

If the behaviors you want is same as my repeated above, I think it's
the default implemention of the Winform datagrid on
master-detail relationship presentation. For how to implement this effect,
you may refer to the following links:

308454 HOW TO: Display Parent and Child Fields Together in a DataGrid by
Using VisualBasic.NET
http://support.microsoft.com/?id=308454

or

308057 HOW TO: Display Parent and Child Fields Together in a Windows Forms
by Using C#.NET
http://support.microsoft.com/?id=308057

However, I remember that you said in the first mail question-1 that you
want to get rid of the procedure of
clicking on the relation name and expand the related items in child table
directly, when there is only one relation defined.
I've sent my current implemention to your e-mailbox, maybe you can give me
some more descriptions about the effect you wish to have. I'll be happy to
put it onto the wishlist if it's really a good idea.

But If you don't want the default behaviors of the treenode, I'm afraid
you couldn't customize it by yourself in current
version of DataGrid. The reason is same as I mentioned in my last reply.

Be free to let me know if you have any questions on this issue, Thanks!


Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.





From: "Bob Day" <[email protected]>
Subject: Re: DataGrid questions
Date: Wed, 6 Aug 2003 11:48:36 -0500
Newsgroups: microsoft.public.dotnet.framework.windowsforms

No, it would look like this:
+ LineNo LineSummary
1 Play Message
-----------------------------------
Now click the + button, and you get:
- LineNo LineSummary
| 1 Play Message
|------> Display Details (which is underlined)
----------------------------------------------
Now click Display Details and you get the details
Line No Summary Detail
1 Play Message File Name: Greeting.wave
-----------------------------------------------

As far as I can see, this is a very straight forward use of a datagrid and
Parent/Child relationships, so I don't understand why the commands
surrounding it aren't ituitieve (i.e. my original questions about above).

Any help would be appreciated.

Thanks!
Bob Day
 
Yes, your description below is accurate. I understand that clicking the +
displays the Relationship Name, which must be clicked to display the
details. THis is default behavior and cannot really be changed.

Here are other questions (re-worded from original).
Question 2 - How can you tell if the child rows for a specific parent row
are displayed?
I would expect "if mygrid.isexpanded(Row0) = true" to tell me that
the datagrid for row 0 is expanded and the child rows are displayed. It
does not. It only tells me that "Display Details" is visible or not.
Toggling
mygrid.expanded and mygrid.collapsed. simply displays or doesn't display the
"Display Details" option. This is pretty useless. How can I determine if a
Parent row is displaying the child rows or not?

Question 3 - With a Parent row expanded to display child rows, how do I
modify the Parent row? You would think that simply modifying the
corresponding DataSet column value would accomplish this, but this generates
an error that I cannot make sense out of. How do you update a Parent Row
while it is expanded shows related child rows?

Question 4 - Updating a Parent row column value (not a column used in
creating the parent/child relationship) seems to always collapse the child
rows for that parent row. Is there a way around this?

Question 5 - Adding child rows to the DataSet does not display them in the
datagrid if the screen is already full with previously child rows. You can,
of course, scroll down to see it. How would you make the last child row
added visible?

Thanks for your help.
Bob

Ying-Shen Yu said:
Hello Bob,
I'm afraid I'm not quite clear about your description. Let me repeat it,

You have two tables in a dataset schema, and there a relation between
the two tables, the datagrid displays the master
table at first, then if you click the '+' next to the item, the grid will
show you the relation name, and if you click
on the relation name, the (whole) grid will navigate to the child
table(ofcourse showing the records related
to the master record only).

If the behaviors you want is same as my repeated above, I think it's
the default implemention of the Winform datagrid on
master-detail relationship presentation. For how to implement this effect,
you may refer to the following links:

308454 HOW TO: Display Parent and Child Fields Together in a DataGrid by
Using VisualBasic.NET
http://support.microsoft.com/?id=308454

or

308057 HOW TO: Display Parent and Child Fields Together in a Windows Forms
by Using C#.NET
http://support.microsoft.com/?id=308057

However, I remember that you said in the first mail question-1 that you
want to get rid of the procedure of
clicking on the relation name and expand the related items in child table
directly, when there is only one relation defined.
I've sent my current implemention to your e-mailbox, maybe you can give me
some more descriptions about the effect you wish to have. I'll be happy to
put it onto the wishlist if it's really a good idea.

But If you don't want the default behaviors of the treenode, I'm afraid
you couldn't customize it by yourself in current
version of DataGrid. The reason is same as I mentioned in my last reply.

Be free to let me know if you have any questions on this issue, Thanks!


Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.





From: "Bob Day" <[email protected]>
Subject: Re: DataGrid questions
Date: Wed, 6 Aug 2003 11:48:36 -0500
Newsgroups: microsoft.public.dotnet.framework.windowsforms

No, it would look like this:
+ LineNo LineSummary
1 Play Message
-----------------------------------
Now click the + button, and you get:
- LineNo LineSummary
| 1 Play Message
|------> Display Details (which is underlined)
----------------------------------------------
Now click Display Details and you get the details
Line No Summary Detail
1 Play Message File Name: Greeting.wave
-----------------------------------------------

As far as I can see, this is a very straight forward use of a datagrid and
Parent/Child relationships, so I don't understand why the commands
surrounding it aren't ituitieve (i.e. my original questions about above).

Any help would be appreciated.

Thanks!
Bob Day

Jonny said:
Hello Bob,
Do you mean the effect like this?

+ LineNo LineDescription
| 1 a Line
--StatusNo Status
1 Playing
2 Idle

To implement this effect, I think you need an event like
OnTreeNodeExpanding and some methods to create the child datagrid by
yourself.
Unfortunately, the Datagrid component neither had a property to change
the behavior of the tree node, nor offered a method/event to override
it.
it
may not be possible to implement this effect.

Regards,
Ying Shen Yu
Microsoft Partner Online Support
This posting is provided "AS IS" with no warranties, and confers no rights.
below to
the relation
in me
that display
the
determine
if You
can,
 
Hi Bob,
Here is part of my answer, please give me some more time to do some
further research on the rest of them, thanks!

Answer to Q2:
You can determining if the datagrid is displaying the child table by
checking the field DataMember of datagrid, the value will be
<mast_table_name>.<relation_name> when the datagrid is displaying the child
rows.
In addition, you may get the index of the corresponding row in parent
table by the dataGrid.CurrentRowIndex.


Answer to Q5:
I don't know if this is an ideal way, but you may try to set the value
of Position in the CurrencyManager
corresponding to the child table, here is an example:

BindingContext bc = dataGrid1.BindingContext;
//get the CurrencyManager of the relation
CurrencyManager cm = bc[cate_ProdDS1,"Categories.Display_Details"] as
CurrencyManager;
if (cm != null)
{
cm.Position = 11;//set to the last index of the child table rows,note
it's zero-based.
}

I hope these answers will be helpful to you.

Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
 
Hello Bob,
I need more information about the error you got in question 3, I would
appreciate if you
can give me an sample project to reproduce your error.
I'v discussed this question 4 with my teammates. Unfortunately, There's
no way to avoid the collapse on child table, when you changing the parent
table. However, I think you may try save the original
value(DataGrid.CurrentRowIndex,and the current row index in child table.
You can find how to get the rowindex of child table in my previous reply)
before updating and restore them right after the update. Be free to let me
know if you meet some further problems. Thanks!



Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
 
Back
Top