本文整理汇总了C#中System.Windows.Forms.ListView.GetItemAtDisplayIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.GetItemAtDisplayIndex方法的具体用法?C# ListView.GetItemAtDisplayIndex怎么用?C# ListView.GetItemAtDisplayIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.GetItemAtDisplayIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawListViewItems
// Drawing
public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
{
bool details = control.View == View.Details;
int first = control.FirstVisibleIndex;
int lastvisibleindex = control.LastVisibleIndex;
#if NET_2_0
if (control.VirtualMode)
control.OnCacheVirtualItems (new CacheVirtualItemsEventArgs (first, lastvisibleindex));
#endif
for (int i = first; i <= lastvisibleindex; i++) {
ListViewItem item = control.GetItemAtDisplayIndex (i);
if (clip.IntersectsWith (item.Bounds)) {
#if NET_2_0
bool owner_draw = false;
if (control.OwnerDraw)
owner_draw = DrawListViewItemOwnerDraw (dc, item, i);
if (!owner_draw)
#endif
{
DrawListViewItem (dc, control, item);
if (control.View == View.Details)
DrawListViewSubItems (dc, control, item);
}
}
}
#if NET_2_0
if (control.UsingGroups) {
// Use InternalCount instead of Count to take into account Default Group as needed
for (int i = 0; i < control.Groups.InternalCount; i++) {
ListViewGroup group = control.Groups.GetInternalGroup (i);
if (group.ItemCount > 0 && clip.IntersectsWith (group.HeaderBounds))
DrawListViewGroupHeader (dc, control, group);
}
}
ListViewInsertionMark insertion_mark = control.InsertionMark;
int insertion_mark_index = insertion_mark.Index;
if (Application.VisualStylesEnabled && insertion_mark.Bounds != Rectangle.Empty &&
(control.View != View.Details && control.View != View.List) &&
insertion_mark_index > -1 && insertion_mark_index < control.Items.Count) {
Brush brush = ResPool.GetSolidBrush (insertion_mark.Color);
dc.FillRectangle (brush, insertion_mark.Line);
dc.FillPolygon (brush, insertion_mark.TopTriangle);
dc.FillPolygon (brush, insertion_mark.BottomTriangle);
}
#endif
// draw the gridlines
#if NET_2_0
if (details && control.GridLines && !control.UsingGroups) {
#else
if (details && control.GridLines) {
#endif
Size control_size = control.ClientSize;
int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
0 : control.header_control.Height;
// draw vertical gridlines
foreach (ColumnHeader col in control.Columns) {
int column_right = col.Rect.Right - control.h_marker;
dc.DrawLine (SystemPens.Control,
column_right, top,
column_right, control_size.Height);
}
// draw horizontal gridlines
int item_height = control.ItemSize.Height;
if (item_height == 0)
item_height = control.Font.Height + 2;
int y = top + item_height - (control.v_marker % item_height); // scroll bar offset
while (y < control_size.Height) {
dc.DrawLine (SystemPens.Control, 0, y, control_size.Width, y);
y += item_height;
}
}
// Draw corner between the two scrollbars
if (control.h_scroll.Visible == true && control.v_scroll.Visible == true) {
Rectangle rect = new Rectangle ();
rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
rect.Width = control.v_scroll.Width;
rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
rect.Height = control.h_scroll.Height;
dc.FillRectangle (SystemBrushes.Control, rect);
}
Rectangle box_select_rect = control.item_control.BoxSelectRectangle;
if (!box_select_rect.Size.IsEmpty)
dc.DrawRectangle (ResPool.GetDashPen (ColorControlText, DashStyle.Dot), box_select_rect);
}