TreeView Indent

6 posts, 0 answers
  1. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 20 Jun 2008 Link to this post

    Hi Telerik,

    I am not able to give the tree view indent value less than 16. Is there any alternative to do this?
     
    please provide some sample code.

    thanks in advance


    regards,
    kiran
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 23 Jun 2008 Link to this post

    Hi kiran,

    Thank you for writing.

    By design, the TreeIndent property cannot be set to a value less than 16. The property uses a field named treeIndent, which is marked as private so you cannot use it to modify the value via the standard ways.

    However, you can set it using the reflection feature of .NET. Here is the code:

               BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                FieldInfo info = radTreeView1.GetType().GetField("treeIndent", flags);
                info.SetValue(radTreeView1, 10);


    If you have any other questions please write me back.

    All the best,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 25 Jun 2008 Link to this post

    Hi Markov,

    The value of field info is coming as null. see the below code for reference.

                radTreeView1.TreeIndent = 16;
                radTreeView1.Update();                   
                
                BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
               
                FieldInfo info = radTreeView1.GetType().GetField("TreeIndent");
                info.SetValue(radTreeView1, 10);

    Could you please share some sample application which changes the tree indent value?

    Any help is highly appreciated.

  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 26 Jun 2008 Link to this post

    Hi Kiran,

    The value of the info is null, because you are not passing the flags parameter to GetField method and also the field variable is a case sensitive, so you should start it with a non-capital letter - "treeIndent". I have attached a sample application which demonstrates this approach.

    If you have further questions, feel free to contact me again.

    Best wishes,
    Nikolay
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 26 Jun 2008 Link to this post

    Hi Nikolay,

    Thanks a lot for your detailed explanation and sample application. it helped me a lot. Now also i got the same problem but when i analyzed the root cause i came to know if we inherit RadTreeView base class we will not be able to do access treeIndent property of the derived class.

    The problem got resolved by directly creating the tree view without using any inheritance.

    Once again, Thanks a lot for your help.

    One small query:

    i have to poulate dates  (Due dates column  from a table in Database) in to tree view like: if the dates are like
    02/06/2008
    03/06/2008
    04/06/2008

    then i need to populate tree view like
    2008
        ----June
                ----Mon02
                ----Tue03
                ----Wed04
     
    is there any direct method to do like this or any workaround to do this?
    Any help is highly appreciated.

    Regards,
    Kiran
  7. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 27 Jun 2008 Link to this post

    Hello kiran,

    I am glad to hear you found my responses helpful.

    However, concerning your last question, there is no direct method to handle the scenario. Unfortunately, I cannot provide you with a workaround.

    If you have additional questions, contact me again.

    Kind regards,
    Nikolay
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready