本文整理汇总了C#中System.Windows.Forms.ListView.SuspendLayout方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.SuspendLayout方法的具体用法?C# ListView.SuspendLayout怎么用?C# ListView.SuspendLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.SuspendLayout方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Popola
public static void Popola(ref ListView aListView, IList aListOfData)
{
aListView.SuspendLayout();
aListView.BeginUpdate();
aListView.Items.Clear();
if (ListUtils.isNotEmpty(aListOfData))
{
foreach (object item in aListOfData)
{
if (item is IListViewItemable)
{
aListView.Items.Add(((IListViewItemable)item).toListViewItem());
}
else if (item is DateTime)
{
ListViewItem dateItem = new ListViewItem(item.ToString());
dateItem.Tag = item;
aListView.Items.Add(dateItem);
}
else
{
aListView.Items.Add(((IListViewItemable)item).ToString());
}
}
}
aListView.EndUpdate();
aListView.ResumeLayout();
}
示例2: FillList
private void FillList(ListView list, DataTable table)
{
list.SuspendLayout();
// Clear list
list.Items.Clear();
list.Columns.Clear();
int colcounter = 1;
// Columns
foreach (DataColumn col in table.Columns)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = col.Caption;
if (IsNumeric(col.DataType))
ch.TextAlign = HorizontalAlignment.Right;
// if 2nd column set width to 150
if (colcounter == 2)
{
ch.Width = 200;
}
else if (colcounter == 1)
{
ch.Width = 80;
}
else if (colcounter == 3)
{
ch.Width = 150;
}
else
{
ch.Width = 70;
}
list.Columns.Add(ch);
colcounter++;
}
// Rows
foreach (DataRow row in table.Rows)
{
ListViewItem item = new ListViewItem();
item.Text = row[0].ToString();
for (int i = 1; i < table.Columns.Count; i++)
{
item.SubItems.Add(row[i].ToString());
}
list.Items.Add(item);
}
list.ResumeLayout();
}
示例3: FillList
private void FillList(ListView lista, DataTable table, int[] ColSize)
{
lista.SuspendLayout();
// Clear list
lista.Items.Clear();
lista.Columns.Clear();
int colcounter = 0;
// Columns
foreach (DataColumn col in table.Columns)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = col.Caption;
if (IsNumeric(col.DataType))
ch.TextAlign = HorizontalAlignment.Right;
if (ColSize != null)
{
if (colcounter < ColSize.Length)
{
ch.Width = ColSize[colcounter];
}
else
{
ch.Width = 80;
}
}
else
{
ch.Width = 80;
}
lista.Columns.Add(ch);
colcounter++;
}
// IMPORTE TOTAL COLUMN
ColumnHeader ch2 = new ColumnHeader();
ch2.Text = "IMPORTE";
ch2.Width = 80;
lista.Columns.Add(ch2);
// Rows
double importetotal = 0;
foreach (DataRow row in table.Rows)
{
ListViewItem item = new ListViewItem();
item.Text = row[0].ToString();
item.SubItems.Add(row[1].ToString());
item.SubItems.Add(row[2].ToString());
item.SubItems.Add(row[3].ToString());
item.SubItems.Add(row[4].ToString());
importetotal += Double.Parse(row[4].ToString());
item.SubItems.Add(importetotal.ToString());
lista.Items.Add(item);
}
// list.ResumeLayout();
}
示例4: ResizeColumnHeaders
/// <summary>
/// Resizes the column headers (maximize the space per column)
/// WARNING: If this is triggered within a Resize event the listview should have
/// a minimum size set to avoid the vertical scroll bar on the column headers themselves.
/// If not properly set the result may be an infinite loop of resize calls.
/// This has no affect on vertical scroll bars for the items within the listview
/// </summary>
/// <param name="lvInput">The listview to update the column widths of</param>
public static void ResizeColumnHeaders(ListView lvInput)
{
if (0 == lvInput.Columns.Count) return; // bad!
if (0 == lvInput.ClientSize.Width) return; // no width? (minimized?)
lvInput.Visible = false;
lvInput.SuspendLayout();
var arrayPercents = new float[lvInput.Columns.Count];
int nColumnsWidth = 0;
for (int nIdx = 0; nIdx < lvInput.Columns.Count; nIdx++)
{
nColumnsWidth += lvInput.Columns[nIdx].Width;
}
for (int nIdx = 0; nIdx < lvInput.Columns.Count; nIdx++)
{
arrayPercents[nIdx] = (float)lvInput.Columns[nIdx].Width / (float)nColumnsWidth;
}
for (int nIdx = 0; nIdx < lvInput.Columns.Count; nIdx++)
{
lvInput.Columns[nIdx].Width = (int)(arrayPercents[nIdx] * (float)lvInput.ClientSize.Width);
}
lvInput.ResumeLayout();
lvInput.Visible = true;
}
示例5: UpdateView
private void UpdateView(ListView list, ExpertRegistry registry)
{
LoggingService.EnterMethod();
list.SuspendLayout();
list.Items.Clear();
foreach (ExpertInfo expert in registry.Experts)
{
AppendTo(list, expert);
}
list.ResumeLayout();
LoggingService.LeaveMethod();
}
示例6: ClearListView
internal static void ClearListView(ListView lst, bool removeRows)
{
try
{
lst.SuspendLayout();
if (removeRows)
{
lst.Items.Clear();
}
else
{
for (var i = 0; i < lst.Items.Count; i++)
{
var subs = lst.Items[i].SubItems;
for (var j = 0; j < subs.Count; j++)
{
subs[j].Text = string.Empty;
}
}
}
}
catch (Exception e)
{
LogHelper.Dump(e);
}
finally
{
lst.ResumeLayout();
}
}
示例7: RemoveSelectedItemsFor
private void RemoveSelectedItemsFor(ListView actualListControl, StoredItemsList storedItemsList) {
ArrayList itemsToRemove = new ArrayList(actualListControl.SelectedItems);
actualListControl.SuspendLayout();
foreach (ListViewItem item in itemsToRemove) {
storedItemsList.Items.Remove(item.Tag);
actualListControl.Items.Remove(item);
}
actualListControl.ResumeLayout();
}
示例8: FillPicturesList
// Fill the list control with a list of all multimedia files associated with the record
private static void FillPicturesList( ListView listView, ArrayList alMultimediaFileRefs )
{
listView.SuspendLayout();
LogFile.TheLogFile.WriteLine( LogFile.DT_APP, LogFile.EDebugLevel.Note, "FillPicturesList() : " + alMultimediaFileRefs.Count.ToString() );
CMultimediaFileReference mfrSelected = null;
CListableMFR lmfr = GetSelectedItem( listView );
if( lmfr != null )
{
mfrSelected = lmfr.MultimediaFileReference;
}
alMultimediaFileRefs.Sort( new CMultimediaFileReference.OrderComparer() );
string sMmFilename;
Cursor.Current = Cursors.WaitCursor;
Cursor.Show();
listView.Items.Clear();
ListViewItem[] temporaryItemsList = new ListViewItem[ alMultimediaFileRefs.Count ];
int nItem = 0;
foreach( CMultimediaFileReference mfr in alMultimediaFileRefs )
{
if( mfr.m_bEmbedded )
{
sMmFilename = "embedded media";
}
else
{
sMmFilename = mfr.m_sMultimediaFileReference;
}
CListableMFR item = new CListableMFR( mfr );
if( mfrSelected == mfr )
{
item.Selected = true;
}
if( mfr.m_bVisible )
{
item.Checked = true;
}
else
{
item.Checked = false;
}
if( sMmFilename != null && sMmFilename.Length > 0)
{
item.SubItems.Add( sMmFilename );
}
temporaryItemsList[ nItem++ ] = item;
}
listView.Items.AddRange( temporaryItemsList );
listView.ResumeLayout();
Cursor.Current = Cursors.Default;
Cursor.Hide();
}
示例9: AutoResizeList
private void AutoResizeList(ListView list, int mainCol)
{
list.SuspendLayout();
int widthAvailable = list.Width - SystemInformation.BorderSize.Width - SystemInformation.VerticalScrollBarWidth;
for (int i = 0; i < list.Columns.Count; i++)
if (i != mainCol)
{
list.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
widthAvailable -= list.Columns[i].Width + SystemInformation.BorderSize.Width;
}
if (list.Columns[mainCol].Width != widthAvailable)
list.Columns[mainCol].Width = widthAvailable;
list.ResumeLayout(false);
}