View previous topic :: View next topic |
Author |
Message |
cpbird
Joined: 29 Mar 2011 Posts: 4
|
Posted: Tue Mar 29, 2011 8:44 am Post subject: About the SelectRow Collapse problem. |
|
|
treProjectList.SelectedRow.ParentRow.Collapse();
When run the function in tree double click Event, the current row's ParentRow can collapse,but the current row's ParentRow next row is Expanded. Why is this? And How to avoid the next row expanded.
Please help me, thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 29, 2011 11:22 pm Post subject: |
|
|
I'm not quite sure what you mean. I've just modified the simple tree sample project and added a button to collapse the parent row of the selected row with the following code:
Code: | private void button1_Click(object sender, EventArgs e)
{
Row parent = _virtualTree.SelectedRow.ParentRow;
parent.Collapse();
} |
This works exactly as I expected; the parent row is collapsed and I don't see any other row expanded. Perhaps if you can replicate the issue you are having in one of the sample projects and email the zipped project to support@infralution.com we could pin down the problem. _________________ Infralution Support |
|
Back to top |
|
|
cpbird
Joined: 29 Mar 2011 Posts: 4
|
Posted: Wed Mar 30, 2011 3:49 am Post subject: |
|
|
I mean that,When double click the tree,the current row' parent row should be Collapsed.
private void tree_DoubleClick(object sender, EventArgs e)
{
if (tree.SelectedItem != null)
{
DataRow dataRow = (DataRow)tree.SelectedItem;
if (dataRow != null)
{
if (dataRow is DSProjectCompare.PhaseRow )
{
AddSelectedProjectRow();
}
if (dataRow is DSProjectCompare.OptionRow)
{
tree.SelectedRow.ParentRow.Collapse();
}
}
}
}
Following the code, the tree have two Level 'Phase','Option',They have Parent-Children ralation.When user double-click the level 'Option'(children),the tree need Collapse the current row's parent row(Collapse the current level 'Option' 's parent level 'Phase').
My problem is double-click a 'Option',the parent 'Phase' can Collapse,but the next 'Phase' expanded or Collapse too.
Thank your help. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 30, 2011 4:23 am Post subject: |
|
|
Collapsing the parent row in the double click event is a very unusual thing to do - since the default action for most tree controls on double click is to toggle the expansion state of the current node (which is what VirtualTree does by default if ExpandOnDoubleClick is true). So your users will be probably be surprised by this behaviour.
Anyway I added the following code to the double click handler
Code: | private void _virtualTree_DoubleClick(object sender, EventArgs e)
{
Row selectedRow = _virtualTree.SelectedRow;
if (selectedRow != null && selectedRow.ParentRow != null)
{
selectedRow.ParentRow.Collapse();
}
} |
Again this worked even if ExpandOnDoubleClick was true. So I think something else is going on in your case. Probably the only way to get to the bottom of the issue is if you can replicate it in a sample projects that you can send to us - so that we know for sure what behaviour you are seeing. _________________ Infralution Support |
|
Back to top |
|
|
|