本文整理汇总了C#中System.Windows.Forms.ListView.PerformLayout方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.PerformLayout方法的具体用法?C# ListView.PerformLayout怎么用?C# ListView.PerformLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.PerformLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetViewMode
private void SetViewMode(ListView view, View newViewMode)
{
// Keep the old column states if we go away from details mode.
// They will be restored later when we go back to details view and have
// added the columns again.
if (view.View == View.Details)
SaveColumnStates(view);
if (view.View != newViewMode)
{
switch (newViewMode)
{
case View.Tile:
view.View = newViewMode;
view.TileSize = new Size(140, 17);
view.LargeImageList = IconManagerWrapper.ImageList16;
break;
case View.LargeIcon:
view.View = newViewMode;
view.LargeImageList = IconManagerWrapper.ImageList48;
break;
case View.Details:
// This call will make the scrollbars visible for a moment but works around a more serious problem.
// When the listview is switched to report mode without scrollbars being visible then it will not adjust
// its client area for the header and parts of the first items are hidden behind the header.
view.Scrollable = true;
view.View = newViewMode;
view.Scrollable = false;
break;
}
// Adjust item image indices, as they might not be the same for large and small icons.
for (int i = 0; i < view.Items.Count; i++)
{
NodeIdWrapper id = (view.Items[i].Tag as Identifier).id;
view.Items[i].ImageIndex = FindImageIndex(id, view.View);
}
view.PerformLayout();
}
}
示例2: PopulateListView
private void PopulateListView(NodeIdWrapper parentNodeId, ListView listView)
{
listView.BeginUpdate();
try
{
int itemCount = wbOverview.count_children(parentNodeId);
ListViewItem[] items = new ListViewItem[itemCount];
int detail_fields_count = wbOverview.get_details_field_count(parentNodeId);
for (int i = 0; i < itemCount; i++)
{
NodeIdWrapper itemNodeId = wbOverview.get_child(parentNodeId, i);
string caption;
wbOverview.get_field(itemNodeId, (int)Overview.Columns.Label, out caption);
ListViewItem item = new ListViewItem(caption, FindImageIndex(itemNodeId, listView.View));
item.Tag = CreateIdentifier(itemNodeId);
item.ToolTipText = caption;
// Add details for that item, if available.
for (int counter = 0; counter < detail_fields_count; counter++)
{
String detailText;
wbOverview.get_field(itemNodeId, (int)Overview.Columns.FirstDetailField + counter, out detailText);
item.SubItems.Add(detailText.Replace(Environment.NewLine, " / "));
}
items[i] = item;
}
listView.Items.Clear();
listView.Items.AddRange(items);
// Setting the sorter also starts sorting.
listView.ListViewItemSorter = new InsensitiveListviewComparer(0, SortOrder.Ascending);
Win32.SetSortIcon(listView, 0, SortOrder.Ascending);
// select stuff
List<int> selected = wbOverview.get_selected_children(parentNodeId);
foreach (int i in selected)
listView.SelectedIndices.Add(i);
}
finally
{
listView.EndUpdate();
listView.PerformLayout();
};
}