本文整理汇总了C#中BrightIdeasSoftware.OLVListItem类的典型用法代码示例。如果您正苦于以下问题:C# OLVListItem类的具体用法?C# OLVListItem怎么用?C# OLVListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OLVListItem类属于BrightIdeasSoftware命名空间,在下文中一共展示了OLVListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatRow
private static void FormatRow(OLVListItem item)
{
var installment = (Installment)item.RowObject;
if (installment == null) return;
if (installment.IsPending) item.BackColor = Color.Orange;
if (installment.IsRepaid) item.BackColor = Color.FromArgb(61, 153, 57);
if (installment.IsPending || installment.IsRepaid) item.ForeColor = Color.White;
}
示例2: CalculateItemBounds
/// <summary>
/// Given the item and the subitem, calculate its bounds.
/// </summary>
/// <param name="item"></param>
/// <param name="subItem"></param>
/// <returns></returns>
public Rectangle CalculateItemBounds(OLVListItem item, OLVListSubItem subItem) {
if (item == null)
return Rectangle.Empty;
if (subItem == null)
return item.Bounds;
else
return item.GetSubItemBounds(item.SubItems.IndexOf(subItem));
}
示例3: ApplyHyperlinkStyle
private void ApplyHyperlinkStyle(int rowIndex, OLVListItem olvi)
{
olvi.UseItemStyleForSubItems = false;
// If subitem 0 is given a back color, the item back color is changed too.
// So we have to remember it here so we can used it even if subitem 0 is changed.
Color itemBackColor = olvi.BackColor;
for (int i = 0; i < this.Columns.Count; i++) {
OLVListSubItem subItem = olvi.GetSubItem(i);
if (subItem == null)
continue;
OLVColumn column = this.GetColumn(i);
subItem.BackColor = itemBackColor;
if (column.Hyperlink && !String.IsNullOrEmpty(subItem.Url)) {
if (this.IsUrlVisited(subItem.Url))
this.ApplyCellStyle(olvi, i, this.HyperlinkStyle.Visited);
else
this.ApplyCellStyle(olvi, i, this.HyperlinkStyle.Normal);
}
}
}
示例4: UpdateHotRow
/// <summary>
/// Update the given row using the current hot item information
/// </summary>
/// <param name="olvi"></param>
protected virtual void UpdateHotRow(OLVListItem olvi)
{
this.UpdateHotRow(this.HotRowIndex, this.HotColumnIndex, this.HotCellHitLocation, olvi);
}
示例5: SetSubItemImages
/// <summary>
/// Tell the underlying list control which images to show against the subitems
/// </summary>
/// <param name="rowIndex">the index at which the item occurs</param>
/// <param name="item">the item whose subitems are to be set</param>
/// <param name="shouldClearImages">will existing images be cleared if no new image is provided?</param>
protected virtual void SetSubItemImages(int rowIndex, OLVListItem item, bool shouldClearImages)
{
if (!this.ShowImagesOnSubItems || this.OwnerDraw)
return;
for (int i = 1; i < item.SubItems.Count; i++) {
this.SetSubItemImage(rowIndex, i, item.GetSubItem(i), shouldClearImages);
}
}
示例6: PostProcessOneRow
/// <summary>
/// Do the work required after one item in a listview have been created
/// </summary>
protected virtual void PostProcessOneRow(int rowIndex, int displayIndex, OLVListItem olvi)
{
if (this.UseAlternatingBackColors && this.View == View.Details) {
if (displayIndex % 2 == 1) {
olvi.BackColor = this.AlternateRowBackColorOrDefault;
} else {
olvi.BackColor = this.BackColor;
}
}
if (this.ShowImagesOnSubItems && !this.VirtualMode) {
this.SetSubItemImages(rowIndex, olvi);
}
if (this.UseHyperlinks) {
this.ApplyHyperlinkStyle(rowIndex, olvi);
}
this.TriggerFormatRowEvent(rowIndex, displayIndex, olvi);
}
示例7: FillInValues
/// <summary>
/// Fill in the given OLVListItem with values of the given row
/// </summary>
/// <param name="lvi">the OLVListItem that is to be stuff with values</param>
/// <param name="rowObject">the model object from which values will be taken</param>
protected virtual void FillInValues(OLVListItem lvi, object rowObject)
{
if (this.Columns.Count == 0)
return;
OLVListSubItem subItem = this.MakeSubItem(rowObject, this.GetColumn(0));
lvi.SubItems[0] = subItem;
lvi.ImageSelector = subItem.ImageSelector;
// Only Details and Tile views have subitems
if (this.View == View.Details) {
for (int i = 1; i < this.Columns.Count; i++) {
lvi.SubItems.Add(this.MakeSubItem(rowObject, this.GetColumn(i)));
}
} else {
if (this.View == View.Tile) {
for (int i = 1; i < this.Columns.Count; i++) {
OLVColumn column = this.GetColumn(i);
if (column.IsTileViewColumn)
lvi.SubItems.Add(this.MakeSubItem(rowObject, column));
}
}
}
// Give the item the same font/colors as the control
lvi.Font = this.Font;
lvi.BackColor = this.BackColor;
lvi.ForeColor = this.ForeColor;
// Set the check state of the row, if we are showing check boxes
if (this.CheckBoxes) {
CheckState? state = this.GetCheckState(lvi.RowObject);
if (state.HasValue)
lvi.CheckState = (CheckState)state;
}
// Give the RowFormatter a chance to mess with the item
if (this.RowFormatter != null) {
this.RowFormatter(lvi);
}
}
示例8: CalculateCellEditorBoundsOwnerDrawn
/// <summary>
/// Calculate the bounds of the edit control for the given item/column, when the listview
/// is being owner drawn.
/// </summary>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <param name="r"></param>
/// <returns>A rectangle that is the bounds of the cell editor</returns>
protected Rectangle CalculateCellEditorBoundsOwnerDrawn(OLVListItem item, int subItemIndex, Rectangle r)
{
IRenderer renderer = null;
if (this.View == View.Details)
renderer = this.GetColumn(subItemIndex).Renderer ?? this.DefaultRenderer;
else
renderer = this.ItemRenderer;
if (renderer == null)
return r;
else {
using (Graphics g = this.CreateGraphics()) {
return renderer.GetEditRectangle(g, r, item, subItemIndex);
}
}
}
示例9: CalculateCellEditorBounds
/// <summary>
/// Calculate the bounds of the edit control for the given item/column
/// </summary>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <returns></returns>
public Rectangle CalculateCellEditorBounds(OLVListItem item, int subItemIndex)
{
Rectangle r;
if (this.View == View.Details)
r = item.GetSubItemBounds(subItemIndex);
else
r = this.GetItemRect(item.Index, ItemBoundsPortion.Label);
if (this.OwnerDraw)
return CalculateCellEditorBoundsOwnerDrawn(item, subItemIndex, r);
else
return CalculateCellEditorBoundsStandard(item, subItemIndex, r);
}
示例10: CalculateCellBounds
/// <summary>
/// Return the bounds of the given cell
/// </summary>
/// <param name="item">The row to be edited</param>
/// <param name="subItemIndex">The index of the cell to be edited</param>
/// <returns>A Rectangle</returns>
public virtual Rectangle CalculateCellBounds(OLVListItem item, int subItemIndex)
{
// We use ItemBoundsPortion.Label rather than ItemBoundsPortion.Item
// since Label extends to the right edge of the cell, whereas Item gives just the
// current text width.
return this.CalculateCellBounds(item, subItemIndex, ItemBoundsPortion.Label);
}
示例11: BuildList
/// <summary>
/// Build/rebuild all the list view items in the list
/// </summary>
/// <param name="shouldPreserveState">If this is true, the control will try to preserve the selection,
/// focused item, and the scroll position (see Remarks)
/// </param>
/// <remarks>
/// <para>
/// Use this method in situations were the contents of the list is basically the same
/// as previously.
/// </para>
/// <para>
/// Due to limitations in .NET's ListView, the scroll position is only preserved if
/// the control is in Details view AND it is not showing groups.
/// </para>
/// </remarks>
public virtual void BuildList(bool shouldPreserveState)
{
if (this.Frozen)
return;
this.ApplyExtendedStyles();
this.ClearHotItem();
int previousTopIndex = this.TopItemIndex;
Point currentScrollPosition = this.LowLevelScrollPosition;
IList previousSelection = new ArrayList();
Object previousFocus = null;
if (shouldPreserveState && this.objects != null) {
previousSelection = this.SelectedObjects;
OLVListItem focusedItem = this.FocusedItem as OLVListItem;
if (focusedItem != null)
previousFocus = focusedItem.RowObject;
}
IEnumerable objectsToDisplay = this.FilteredObjects;
this.BeginUpdate();
try {
this.Items.Clear();
this.ListViewItemSorter = null;
if (objectsToDisplay != null) {
// Build a list of all our items and then display them. (Building
// a list and then doing one AddRange is about 10-15% faster than individual adds)
List<OLVListItem> itemList = new List<OLVListItem>();
foreach (object rowObject in objectsToDisplay) {
OLVListItem lvi = new OLVListItem(rowObject);
this.FillInValues(lvi, rowObject);
itemList.Add(lvi);
}
this.Items.AddRange(itemList.ToArray());
this.Sort();
if (shouldPreserveState) {
this.SelectedObjects = previousSelection;
this.FocusedItem = this.ModelToItem(previousFocus);
}
this.RefreshHotItem();
}
} finally {
this.EndUpdate();
}
// We can only restore the scroll position after the EndUpdate() because
// of caching that the ListView does internally during a BeginUpdate/EndUpdate pair.
if (shouldPreserveState) {
this.RefreshHotItem();
// Restore the scroll position. TopItemIndex is best, but doesn't work
// when the control is grouped.
if (this.ShowGroups)
this.LowLevelScroll(currentScrollPosition.X, currentScrollPosition.Y);
else
this.TopItemIndex = previousTopIndex;
}
}
示例12: CellEditEventArgs
/// <summary>
/// Create an event args
/// </summary>
/// <param name="column"></param>
/// <param name="control"></param>
/// <param name="r"></param>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
public CellEditEventArgs(OLVColumn column, Control control, Rectangle r, OLVListItem item, int subItemIndex) {
this.Control = control;
this.column = column;
this.cellBounds = r;
this.listViewItem = item;
this.rowObject = item.RowObject;
this.subItemIndex = subItemIndex;
this.value = column.GetValue(item.RowObject);
}
示例13: TreeBranchCollapsedEventArgs
/// <summary>
/// Create a new event args
/// </summary>
/// <param name="model"></param>
/// <param name="item"></param>
public TreeBranchCollapsedEventArgs(object model, OLVListItem item)
{
this.Model = model;
this.Item = item;
}
示例14: TreeBranchExpandingEventArgs
/// <summary>
/// Create a new event args
/// </summary>
/// <param name="model"></param>
/// <param name="item"></param>
public TreeBranchExpandingEventArgs(object model, OLVListItem item)
{
this.Model = model;
this.Item = item;
}
示例15: SubItemCheckingEventArgs
/// <summary>
/// Create a new event block
/// </summary>
/// <param name="column"></param>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <param name="currentValue"></param>
/// <param name="newValue"></param>
public SubItemCheckingEventArgs(OLVColumn column, OLVListItem item, int subItemIndex, CheckState currentValue, CheckState newValue) {
this.column = column;
this.listViewItem = item;
this.subItemIndex = subItemIndex;
this.currentValue = currentValue;
this.newValue = newValue;
}