Home Forums WinForms controls Other WinForms controls SmartTreeView multi selection

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18405 |

    Hello guys,

    Please tell me is it possible to do a multi selection in a SmartTreeView? I’ve read some posts regarding this issue.On that time, this control did not provide such a feature. Maybe you’d added it in a newest version?
    If the feature is not included, then how could I reproduce this functionality using a workaround?

    Thanks,
    Bogdan

    Imported from legacy forums. Posted by bogdip (had 5102 views)

    Xceed Support
    Member
    Post count: 5658

    No, this feature has not been added to the control.

    As a workaround, you could manage your own selection. For example, using the ForeColor attribute as the selection marker and managing your own list of SmartItem.

    <code>
    private void Form1_Load( object sender, EventArgs e )
    {
    for(int i=0;i<10;i++)
    {
    smartTreeView1.Items.Add( “Item ” + i.ToString() );
    for( int j = 0; j < 5; j++ )
    {
    smartTreeView1.Items[i].Items.Add( “Sub Item ” + j.ToString() );
    for( int k = 0; k < 3; k++ )
    {
    smartTreeView1.Items[ i ].Items[j].Items.Add( “Sub Sub Item ” + k.ToString() );
    }
    }
    }
    //To have the exact text color
    baseColor = smartTreeView1.Items[ 0 ].ForeColor;
    mySelectedList = new List<SmartItem>();
    smartTreeView1.MouseDown += new MouseEventHandler( smartTreeView1_MouseDown );
    }

    private Color baseColor;
    //Your list of SmartItem
    private List<SmartItem> mySelectedList;

    void smartTreeView1_MouseDown( object sender, MouseEventArgs e )
    {
    if( e.Button == MouseButtons.Left )
    {
    if( smartTreeView1.SelectedItem.ForeColor == baseColor )
    {
    //Select
    smartTreeView1.SelectedItem.ForeColor = Color.Red;
    mySelectedList.Add( smartTreeView1.SelectedItem );
    }
    else
    {
    //Unselect
    smartTreeView1.SelectedItem.ForeColor = baseColor;
    mySelectedList.Remove( smartTreeView1.SelectedItem );
    }
    }
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 395 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, the tip is good but how can I change the background color of a selected tree item too (SmartItem or quite a Node) ? The SmartItem has only a ForeColor property.

    Thanks,
    Bogdan

    Imported from legacy forums. Posted by bogdip (had 483 views)

    Xceed Support
    Member
    Post count: 5658

    This is a limitation of the product. The SmartItems (Nodes) of the SmartTreeView only have the ForeColor property, they don’t have the BackColor property. It is by design.

    Imported from legacy forums. Posted by CharlesB (had 436 views)

    User (Old forums)
    Member
    Post count: 23064

    I see, so I think is useless to ask if I can select the entire row like FullRowSelect property does for the System.Windows.Forms.TreeView. Or some workaround for achieving same result?

    Thanks,
    Bogdan

    Imported from legacy forums. Posted by bogdip (had 547 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello all,

    Maybe someone is interested on this last issue. I found a solution to select the entire row by creating a new TreeViewLayout derived from SmartTreeView, and overwriting the CreateDefaultLayout method of the SmartTreeView control to return an instance of this new layout.

    Best regards,
    Bogdan

    Imported from legacy forums. Posted by bogdip (had 6036 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.