Posted
on May 3, 2011
(permalink)
Hello, i just whant to ask if sombady can tellme if this way to fill my treeview looks correctley.
I have this this calss:
public class ReportType {
public string Name { get; set; }
public string[] PropertyNames { get; set; }
public string[] PropertyTypes { get; set; }
}
And i have a list with this type of object. (Top)
So what i whant to do, is fill my radtreeview with this objects, final result loocks like this
Node1
<b>SubNode1.1(Type)</b> + " " + SubNode1.1(Name)
<b>SubNode1.1(Type)</b> + " " + SubNode1.1(Name)
Node2
<b>SubNode1.2(Type)</b> + " " + SubNode1.2(Name)
<b>SubNode1.2(Type)</b> + " " + SubNode1.2(Name)
So i have 2 parameteres (Type and Name) in each subnode text, and the first in BOLD. So that i do is the fallow:
EntitiesTreeView.Nodes.Clear();
ReportType[] types = this.Presenter.ReportGenerator.Types;
foreach (ReportType type in types) {
RadTreeNode node = new RadTreeNode();
node.Text = type.Name;
for (int i = 0; i <= type.PropertyNames.Count() - 1; i++) {
RadTreeNode nodeProperty = new RadTreeNode();
nodeProperty.Controls.Add(GetTable(type.PropertyTypes[i], type.PropertyNames[i]));
node.Nodes.Add(nodeProperty);
}
EntitiesTreeView.Nodes.Add(node);
}
private HtmlTable GetTable(string propertyType, string propertyName) {
HtmlTable table = new HtmlTable();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cellPropertyType = new HtmlTableCell();
cellPropertyType.InnerHtml = "<b>" + propertyType + "</b>";
row.Cells.Add(cellPropertyType);
HtmlTableCell cellPropertyName = new HtmlTableCell();
cellPropertyName.InnerText = propertyName;
row.Cells.Add(cellPropertyName);
table.Rows.Add(row);
return table;
}
Is this way looks nice? (Just whant to know if looks correctley)
Thnx in advance.