radListView1.ItemValueChanged += (s, e) => { Edited.Add(
new
ListViewEditedItems() { Loan = e.ListViewElement.Columns[0].ToString(), Recovery = e.ListViewElement.Columns[1].ToString(), CurrInstNo = e.ListViewElement.Columns[2].ToString(), TotInstNo = e.ListViewElement.Columns[3].ToString(), AmtDrawn = e.ListViewElement.Columns[4].ToString(), AmtRecoverd = e.ListViewElement.Columns[5].ToString(), BalAmt = e.ListViewElement.Columns[6].ToString() }); };
List<WorkItem> _workitems =
new
List<WorkItem>();
List<GridViewDataColumn> _workitemColumns =
new
List<GridViewDataColumn>();
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"InstanceID"
, HeaderText =
"Instance ID"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"StorageObjectID"
, HeaderText =
"Object ID"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"Document.BatchID"
, HeaderText =
"Batch ID"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"ReferenceTypeName"
, HeaderText =
"Document Type"
});
_workitemColumns.Add(
new
GridViewDateTimeColumn() { DataField =
"CreateDate"
, HeaderText =
"Create Date"
, ExcelExportType = DisplayFormatType.Custom, ExcelExportFormatString =
"MM/dd/yyyy hh:mm:ss"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"Title"
, HeaderText =
"Title"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"OwningUser"
, HeaderText =
"Assigned User"
});
_workitemColumns.Add(
new
GridViewTextBoxColumn() { DataField =
"Status"
, HeaderText =
"Status"
});
#region this works
foreach
(GridViewDataColumn curCol
in
this
._workitemColumns)
{
this
.workItemsGridView1.Columns.Add(curCol);
}
BindingList<WorkItem> bindingWorkitems =
new
BindingList<WorkItem>(
this
._workitems);
BindingSource dbBindSource =
new
BindingSource();
dbBindSource.DataSource = bindingWorkitems;
this
.workItemsGridView1.DataSource = dbBindSource;
#endregion
#region does not work
DataTable workitemsDT =
this
._workitems.ToDataTable();
foreach
(GridViewDataColumn curCol
in
this
._workitemColumns)
{
this
.workItemsGridView1.Columns.Add(curCol);
}
foreach
(GridViewDataColumn curCol
in
this
._layerColumns[
this
._selectedLayer])
{
this
.workItemsGridView1.Columns.Add(curCol);
}
this
.workItemsGridView1.DataSource = workitemsDT;
#endregion
public
static
DataTable ToDataTable<T>(
this
List<T> items)
{
var tb =
new
DataTable(
typeof
(T).Name);
PropertyInfo[] props =
typeof
(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach
(var prop
in
props)
{
if
(prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() ==
typeof
(Nullable<>))
{
tb.Columns.Add(prop.Name, prop.PropertyType.GetGenericArguments()[0]);
}
else
tb.Columns.Add(prop.Name, prop.PropertyType);
}
foreach
(var item
in
items)
{
var values =
new
object
[props.Length];
for
(var i = 0; i < props.Length; i++)
{
values[i] = props[i].GetValue(item,
null
);
}
tb.Rows.Add(values);
}
return
tb;
}
private
void
SignalTreeView_NodeFormatting(
object
sender, TreeNodeFormattingEventArgs e)
{
DataRowView rowView = (DataRowView)e.Node.DataBoundItem;
e.NodeElement.ImageElement.Image = (Image)rowView[TreeNodes.COL_ICON];
TreeNode tn = rowView[TreeNodes.COL_ITEM]
as
TreeNode;
if
(tn
is
FolderNode && e.Node.Nodes.Count == 0)
{
e.NodeElement.Visibility = ElementVisibility.Collapsed;
}
}
With radGridView
Dim dtFromCol As New GridViewDateTimeColumn("FromDate")
With dtFromCol
.Format = DateTimePickerFormat.Custom
.CustomFormat = "M/d/yy" 'I'm looking for the shortest date format, i.e. 1/1/12 or 12/31/12
.Width = 70
End With
.Columns.Add(dtFromCol)
.
.Other columns follow
.
End With
When I click the cell I get the datetime picker & the date selected shows up in the desired format (M/d/yy) in the cell, but when I click or Tab away from the cell the cell value changes to a long date format like 2/14/2012 12:00:00 AM . I'm trying not to display the full year (2012) and I don't want the time.
I have tryed customizing the cell's editor in the CellEditorInitialized event or forcing the desired date into the cell in the CellValidated event to no avail. Thanks for any help.
if
(expanded.Contains(item.DataBoundItem))
{
item.IsExpanded =
true;
}