This is a migrated thread and some comments may be shown as answers.

TreeView Indent

5 Answers 156 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
kiran
Top achievements
Rank 1
kiran asked on 20 Jun 2008, 12:14 PM
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

5 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 23 Jun 2008, 02:05 PM
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
0
kiran
Top achievements
Rank 1
answered on 26 Jun 2008, 04:46 AM
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.

0
Nikolay
Telerik team
answered on 26 Jun 2008, 07:19 AM
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
0
kiran
Top achievements
Rank 1
answered on 26 Jun 2008, 11:57 AM
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
0
Nikolay
Telerik team
answered on 27 Jun 2008, 01:38 PM
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
Tags
Treeview
Asked by
kiran
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
kiran
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or