本文整理汇总了C#中BrightIdeasSoftware.OLVListItem.GetSubItem方法的典型用法代码示例。如果您正苦于以下问题:C# OLVListItem.GetSubItem方法的具体用法?C# OLVListItem.GetSubItem怎么用?C# OLVListItem.GetSubItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BrightIdeasSoftware.OLVListItem
的用法示例。
在下文中一共展示了OLVListItem.GetSubItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: TriggerFormatRowEvent
/// <summary>
/// Trigger FormatRow and possibly FormatCell events for the given item
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="displayIndex"></param>
/// <param name="olvi"></param>
protected virtual void TriggerFormatRowEvent(int rowIndex, int displayIndex, OLVListItem olvi)
{
FormatRowEventArgs args = new FormatRowEventArgs();
args.ListView = this;
args.RowIndex = rowIndex;
args.DisplayIndex = displayIndex;
args.Item = olvi;
args.UseCellFormatEvents = this.UseCellFormatEvents;
this.OnFormatRow(args);
if (args.UseCellFormatEvents && this.View == View.Details) {
// If a cell isn't given its own color, it should use the color of the item.
// However, there is a bug in the .NET framework where the cell are given
// the color of the ListView instead. So we have to explicitly give each
// cell the back color that it should have.
olvi.UseItemStyleForSubItems = false;
Color backColor = olvi.BackColor;
for (int i = 0; i < this.Columns.Count; i++) {
olvi.SubItems[i].BackColor = backColor;
}
// Fire one event per cell
FormatCellEventArgs args2 = new FormatCellEventArgs();
args2.ListView = this;
args2.RowIndex = rowIndex;
args2.DisplayIndex = displayIndex;
args2.Item = olvi;
for (int i = 0; i < this.Columns.Count; i++) {
args2.ColumnIndex = i;
args2.Column = this.GetColumn(i);
args2.SubItem = olvi.GetSubItem(i);
this.OnFormatCell(args2);
}
}
}
示例3: UpdateHotRow
/// <summary>
/// Update the given row using the given hot item information
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="columnIndex"></param>
/// <param name="hitLocation"></param>
/// <param name="olvi"></param>
protected virtual void UpdateHotRow(int rowIndex, int columnIndex, HitTestLocation hitLocation, OLVListItem olvi)
{
if (rowIndex < 0 || columnIndex < 0)
return;
if (this.UseHyperlinks) {
OLVColumn column = this.GetColumn(columnIndex);
OLVListSubItem subItem = olvi.GetSubItem(columnIndex);
if (column.Hyperlink && hitLocation == HitTestLocation.Text && !String.IsNullOrEmpty(subItem.Url)) {
this.ApplyCellStyle(olvi, columnIndex, this.HyperlinkStyle.Over);
this.Cursor = this.HyperlinkStyle.OverCursor ?? Cursors.Default;
} else {
this.Cursor = Cursors.Default;
}
}
if (this.UseHotItem) {
if (!olvi.Selected) {
this.ApplyRowStyle(olvi, this.HotItemStyle);
}
}
}
示例4: CalculateCellEditorBoundsStandard
/// <summary>
/// Calculate the bounds of the edit control for the given item/column, when the listview
/// is not being owner drawn.
/// </summary>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <param name="cellBounds"></param>
/// <param name="preferredSize"> </param>
/// <returns>A rectangle that is the bounds of the cell editor</returns>
protected Rectangle CalculateCellEditorBoundsStandard(OLVListItem item, int subItemIndex, Rectangle cellBounds, Size preferredSize) {
if (this.View != View.Details)
return cellBounds;
// Allow for image (if there is one).
int offset = 0;
object imageSelector = null;
if (subItemIndex == 0)
imageSelector = item.ImageSelector;
else {
// We only check for subitem images if we are owner drawn or showing subitem images
if (this.OwnerDraw || this.ShowImagesOnSubItems)
imageSelector = item.GetSubItem(subItemIndex).ImageSelector;
}
if (this.GetActualImageIndex(imageSelector) != -1) {
offset += this.SmallImageSize.Width + 2;
}
// Allow for checkbox
if (this.CheckBoxes && this.StateImageList != null && subItemIndex == 0) {
offset += this.StateImageList.ImageSize.Width + 2;
}
// Allow for indent (first column only)
if (subItemIndex == 0 && item.IndentCount > 0) {
offset += (this.SmallImageSize.Width * item.IndentCount);
}
// Do the adjustment
if (offset > 0) {
cellBounds.X += offset;
cellBounds.Width -= offset;
}
return cellBounds;
}
示例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: GetEditRectangle
/// <summary>
/// Calculate the edit rectangle
/// </summary>
/// <param name="g"></param>
/// <param name="cellBounds"></param>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <param name="preferredSize"> </param>
/// <returns></returns>
public override Rectangle GetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex, Size preferredSize)
{
this.ClearState();
this.ListView = (ObjectListView) item.ListView;
this.ListItem = item;
this.SubItem = item.GetSubItem(subItemIndex);
this.Column = this.ListView.GetColumn(subItemIndex);
this.RowObject = item.RowObject;
this.IsItemSelected = this.ListItem.Selected && this.ListItem.Enabled;
this.Bounds = cellBounds;
return this.HandleGetEditRectangle(g, cellBounds, item, subItemIndex, preferredSize);
}
示例7: GetEditRectangle
/// <summary>
/// Calculate the edit rectangle
/// </summary>
/// <param name="g"></param>
/// <param name="cellBounds"></param>
/// <param name="item"></param>
/// <param name="subItemIndex"></param>
/// <returns></returns>
public override Rectangle GetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex)
{
ClearState();
ListView = (ObjectListView) item.ListView;
ListItem = item;
SubItem = item.GetSubItem(subItemIndex);
Column = ListView.GetColumn(subItemIndex);
RowObject = item.RowObject;
IsItemSelected = ListItem.Selected;
Bounds = cellBounds;
return HandleGetEditRectangle(g, cellBounds, item, subItemIndex);
}
示例8: RefreshItem
/// <summary>
/// Rebuild the given ListViewItem with the data from its associated model.
/// </summary>
/// <remarks>This method does not resort or regroup the view. It simply updates
/// the displayed data of the given item</remarks>
public virtual void RefreshItem(OLVListItem olvi) {
olvi.UseItemStyleForSubItems = true;
olvi.SubItems.Clear();
this.FillInValues(olvi, olvi.RowObject);
if (this.GetColumn(0).IsRowNumberColumn)
{
int idx = olvi.Index;
olvi.GetSubItem(0).Text = (++idx).ToString();
}
this.PostProcessOneRow(olvi.Index, this.GetDisplayOrderOfItemIndex(olvi.Index), olvi);
}
示例9: InsertObjects
/// <summary>
/// Insert the given collection of objects before the given position
/// </summary>
/// <param name="index">Where to insert the objects</param>
/// <param name="modelObjects">The objects to be inserted</param>
/// <remarks>
/// <para>
/// This operation only makes sense of non-sorted, non-grouped
/// lists, since any subsequent sort/group operation will rearrange
/// the list.
/// </para>
/// <para>This method only works on ObjectListViews and FastObjectListViews.</para>
///</remarks>
public virtual void InsertObjects(int index, ICollection modelObjects) {
if (this.InvokeRequired) {
this.Invoke((MethodInvoker)delegate() {
this.InsertObjects(index, modelObjects);
});
return;
}
if (modelObjects == null)
return;
this.BeginUpdate();
try {
// Give the world a chance to cancel or change the added objects
ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects);
this.OnItemsAdding(args);
if (args.Canceled)
return;
modelObjects = args.ObjectsToAdd;
this.TakeOwnershipOfObjects();
ArrayList ourObjects = ObjectListView.EnumerableToArray(this.Objects, false);
// If we are filtering the list, there is no way to efficiently
// insert the objects, so just put them into our collection and rebuild.
if (this.IsFiltering) {
index = Math.Max(0, Math.Min(index, ourObjects.Count));
ourObjects.InsertRange(index, modelObjects);
this.BuildList(true);
} else {
this.ListViewItemSorter = null;
index = Math.Max(0, Math.Min(index, this.GetItemCount()));
int i = index;
foreach (object modelObject in modelObjects) {
if (modelObject != null) {
ourObjects.Insert(i, modelObject);
OLVListItem lvi = new OLVListItem(modelObject);
this.FillInValues(lvi, modelObject);
if (this.GetColumn(0).IsRowNumberColumn)
{
lvi.GetSubItem(0).Text = (i+1).ToString();
}
this.Items.Insert(i, lvi);
i++;
}
}
for (i = index; i < this.GetItemCount(); i++) {
OLVListItem lvi = this.GetItem(i);
this.SetSubItemImages(lvi.Index, lvi);
}
this.PostProcessRows();
}
UpdateRowNumber();
// Tell the world that the list has changed
this.SubscribeNotifications(modelObjects);
this.OnItemsChanged(new ItemsChangedEventArgs());
} finally {
this.EndUpdate();
}
}
示例10: 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>
/// </remarks>
public virtual void BuildList(bool shouldPreserveState) {
if (this.Frozen)
return;
Stopwatch sw = Stopwatch.StartNew();
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)
int rowNo = 1;
List<ListViewItem> itemList = new List<ListViewItem>(); // use ListViewItem to avoid co-variant conversion
foreach (object rowObject in objectsToDisplay) {
OLVListItem lvi = new OLVListItem(rowObject);
this.FillInValues(lvi, rowObject);
if (this.GetColumn(0).IsRowNumberColumn)
{
lvi.GetSubItem(0).Text = (rowNo++).ToString();
}
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;
}
System.Diagnostics.Debug.WriteLine(String.Format("PERF - Building list for {2} objects took {0}ms / {1} ticks", sw.ElapsedMilliseconds, sw.ElapsedTicks, this.GetItemCount()));
}