Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:58:07+00:00 2026-06-07T17:58:07+00:00

How to let the TreeView to change its width when expanding node so that

  • 0

How to let the TreeView to change its width when expanding node so that the label of node will completely show.

First I set the DrawMode = OwnerDrawAll;

Then handle the event DrawNode andin handler

e.DrawDefault = true;
currentWith_ = Math.Max(currentWith_, e.Node.Bounds.Right);

and then in AfterExpand sets the control with. But is not works every time. Sometimes the with is not changed or changed not correctly.

How to correct this problem.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:58:08+00:00Added an answer on June 7, 2026 at 5:58 pm

    Try this one, this works successfully:

    private void treeViewAfterExpand(object sender, TreeViewEventArgs e)
    {
        int maxRight = treeView.ClientSize.Width;
    
        if(e.Node.Nodes != null)
            foreach (TreeNode node in e.Node.Nodes)
            {
                maxRight = Math.Max(maxRight, node.Bounds.Right);
            }
    
        treeView.ClientSize = new Size(maxRight, treeView.ClientSize.Height);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let me explain more detail. First of all; I know that if user press
Let's say that I have a SQLite database that I create in a separate
This sounds like a tricky question... let me ellaborate... I have a treeView. When
I have a TreeView which will be populated with some Nodes. The problem is,
Let's say after I had login I will be prompt to enter the Name
Let assume we have two activities. A - main activity, that is home launcher
Let's say you have a method that expects a numerical value as an argument.
Let's say I have a bunch of links that share a click event: <a
I created a piece of code that will display an appropriate groupbox corresponding to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.