locked
Questions About.... RRS feed

  • Question

  • The View Tree In C# 2005

    1) How do I add images to it?

    2) Do I need to use coding to add images to it; because according to all help topics I have found that is the case?

    3) How can I have it Hide like that in C# 2005 (i. e. the toolbar).

    Saturday, March 10, 2007 3:55 AM

Answers

  • Yes you can add images at design time (without using code).

    1. Add an  ImageList control to to your form.  You will find it in the "Components" section of the toolbox.

    2. In the properties window of the newly added ImageList, click on Images.  You will see a dialog box in which you can add images.

    3. Select your TreeView component and in the properties window, select ImageList and in the dropdown, select the name of your newly created image list (imageList1 perhaps).

    4. Click on the little triangle in the upper right corner of your TreeView control and select Edit Notes.

    5. Click on a node to be edited and in the ImageIndex dropdown, select the image you would like to display for that node.

     

    Hope this works for you.

    Saturday, March 10, 2007 1:00 PM
  • Hi,

    About last question you mentioned, it is something you can design for yourself.

    My idea is make treeview's width to be changed as mouse hover or leave.

    Here is the sample code:

            bool expand = true;

            private void timer1_Tick(object sender, EventArgs e)

            {

                if (expand)

                {

                    if (treeView1.Width < 100)

                        treeView1.Width += 5;

                    else

                        timer1.Stop();

                }

                else

                {

                    if (treeView1.Width > 15)

                        treeView1.Width -= 5;

                    else

                        timer1.Stop();

                }

            }

     

            private void treeView1_MouseHover(object sender, EventArgs e)

            {

                expand = true;

                timer1.Start();

            }

            private void treeView1_MouseLeave(object sender, EventArgs e)

            {

                expand = false;

                timer1.Start();

            }

    I tried to set Interval of timer1 to 10 milliseconds, and it looks well.

    Of course, you can set all the numbers as you like.

    Thank you

    Monday, March 12, 2007 4:23 AM

All replies

  • Saturday, March 10, 2007 4:52 AM
  • I already know about that usless stuff. As I stated above I did a search. I am new and I don't see why I have to code the images in when I dont have to do it for stuff like the Tool Strip & Menu Strip. Do you know of any (or perhaps could make) a sample program so I can run it then look at the source code as I learn better that way.
    Saturday, March 10, 2007 5:37 AM
  • Yes you can add images at design time (without using code).

    1. Add an  ImageList control to to your form.  You will find it in the "Components" section of the toolbox.

    2. In the properties window of the newly added ImageList, click on Images.  You will see a dialog box in which you can add images.

    3. Select your TreeView component and in the properties window, select ImageList and in the dropdown, select the name of your newly created image list (imageList1 perhaps).

    4. Click on the little triangle in the upper right corner of your TreeView control and select Edit Notes.

    5. Click on a node to be edited and in the ImageIndex dropdown, select the image you would like to display for that node.

     

    Hope this works for you.

    Saturday, March 10, 2007 1:00 PM
  • Yes, but I found it on my own; thanks any way. And also if you read my first post this topic has 3 questions for the View Tree and only 2 have been answered.
    Sunday, March 11, 2007 7:40 PM
  • Hi,

    About last question you mentioned, it is something you can design for yourself.

    My idea is make treeview's width to be changed as mouse hover or leave.

    Here is the sample code:

            bool expand = true;

            private void timer1_Tick(object sender, EventArgs e)

            {

                if (expand)

                {

                    if (treeView1.Width < 100)

                        treeView1.Width += 5;

                    else

                        timer1.Stop();

                }

                else

                {

                    if (treeView1.Width > 15)

                        treeView1.Width -= 5;

                    else

                        timer1.Stop();

                }

            }

     

            private void treeView1_MouseHover(object sender, EventArgs e)

            {

                expand = true;

                timer1.Start();

            }

            private void treeView1_MouseLeave(object sender, EventArgs e)

            {

                expand = false;

                timer1.Start();

            }

    I tried to set Interval of timer1 to 10 milliseconds, and it looks well.

    Of course, you can set all the numbers as you like.

    Thank you

    Monday, March 12, 2007 4:23 AM