or
// with clear value option
var timeOnlyColumn =
new
GridViewDateTimeColumn
{
HeaderText =
"Time in"
,
Name = Data.cJobCardData.JobCardColumns.DateTimeIn,
FieldName = Data.cJobCardData.JobCardColumns.DateTimeIn,
Format = DateTimePickerFormat.Time,
EditorType = GridViewDateTimeEditorType.TimePicker,
FormatString =
"{0: h:mm tt}"
,
TextAlignment = ContentAlignment.MiddleCenter,
Width = colWidth
};
// No clear value option
var dateColumnIn =
new
GridViewDateTimeColumn
{
HeaderText =
"Date Time In"
,
Name = Data.cJobCardData.JobCardColumns.DateTimeIn,
FieldName = Data.cJobCardData.JobCardColumns.DateTimeIn,
Format = DateTimePickerFormat.Long,
EditorType = GridViewDateTimeEditorType.TimePicker,
FormatString =
"{0: M/d/yyyy h:mm tt}"
,
TextAlignment = ContentAlignment.MiddleCenter,
Width = colWidth
};
public partial class Form1 : Form
{
BindingList<
Thing
> RootChildren;
int currentId = 1;
public Form1()
{
InitializeComponent();
}
private void buttonLoad_Click(object sender, EventArgs e)
{
radTreeView1.DataSource = null;
RootChildren = new BindingList<
Thing
>();
Thing t1 = new Thing(1, "One");
Thing t2 = new Thing(2, "Two");
Thing t3 = new Thing(3, "Three");
Thing t4 = new Thing(4, "Four");
currentId = 5;
RootChildren.Add(t1);
RootChildren.Add(t2);
RootChildren.Add(t3);
RootChildren.Add(t4);
radTreeView1.DataSource = RootChildren;
radTreeView1.ChildMember = @"Children\Children\Children\Children";
radTreeView1.ValueMember = "Id";
radTreeView1.DisplayMember = "Name";
}
private void buttonClear_Click(object sender, EventArgs e)
{
radTreeView1.DataSource = null;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
Thing thing = new Thing(currentId, "NewThing" + currentId);
RootChildren.Add(thing);
currentId++;
RootChildren.ResetBindings();
}
}
public class Thing
{
public int Id { get; set; }
public string Name { get; set; }
public BindingList<
Thing
> Children = new BindingList<
Thing
>();
public Thing() { }
public Thing(int id, string name)
{
Id = id;
Name = name;
}
}