本文整理汇总了C#中System.Windows.Forms.ListView.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Clear方法的具体用法?C# ListView.Clear怎么用?C# ListView.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
//────────────────────────────────────────
/// <summary>
/// リスト・ビュー1の内容を、リスト・ビュー2へ、コピーします。
/// </summary>
/// <param name="listView"></param>
/// <param name="listView"></param>
public void CopyTo(ListView listView1, ListView listView2, Log_Reports log_Reports)
{
// リスト・ビュー2を空にします。
listView2.Clear();
// 編集テーブルを、並び順変更先テーブルにコピーします。
foreach (ColumnHeader columnHeader in listView1.Columns)
{
listView2.Columns.Add(columnHeader.Text);
}
foreach (ListViewItem listViewItem in listView1.Items)
{
// [0]列目を初期値として設定します。
ListViewItem newItem = new ListViewItem(listViewItem.Text);
// 最初の[0]列目は既に追加済みなので、[1]列目以降から追加します。
for (int nIndex = 1; nIndex < listViewItem.SubItems.Count; nIndex++)
{
newItem.SubItems.Add(listViewItem.SubItems[nIndex]);
}
listView2.Items.Add(newItem);
}
goto gt_EndMethod;
//
gt_EndMethod:
;
}
示例2: InitialListView
public void InitialListView(ListView listView)
{
listView.Clear();
InsertAllColumns(listView);
listView.BeginUpdate();
AddFlowItem(listView);
listView.EndUpdate();
}
示例3: RefreshUpdate
public void RefreshUpdate(ListView listview, TabPage tab)
{
getpack = new GetPackage(packages);
IEnumerable<IPackage> localPackages = getpack.GetPackagesFromExtensions(App.Extensions);
if (localPackages.Count() > 0)
{
IEnumerable<IPackage> list = null;
try
{
list = packages.Repo.GetUpdates(localPackages, false, false);
}
catch (WebException)
{
listview.Invoke((Action)(() =>
{
listview.Clear();
listview.Items.Add("Updates could not be retrieved for the selected feed.");
listview.Items.Add("Try again later or change the feed.");
}));
}
listview.Invoke((Action)(() =>
{
listview.Clear();
int Count = list.Count();
tab.Text = String.Format("Updates ({0})", Count);
Add.AddPackages(list, listview, 0);
if (listview.Items.Count == 0)
{
listview.Clear();
listview.Items.Add("No updates available for the selected feed.");
}
}));
}
else
{
listview.Invoke((Action)(() =>
{
listview.Clear();
listview.Items.Add("No packages are installed.");
}));
}
}
示例4: FillListView
public static void FillListView(ListView _listView, List<IBaseElement> _listEl)
{
_listView.Clear();
_listView.BeginUpdate();
foreach (IBaseElement row in _listEl)
{
var item = new ListViewItem(row.name);
_listView.Items.Add(item);
}
_listView.EndUpdate();
}
示例5: updateOnlineUserList
public void updateOnlineUserList(ListView onlineUserList)
{
if (onlineUserList.InvokeRequired)
{
// We're on a thread other than the GUI thread
onlineUserList.Invoke(new MethodInvoker(() => updateOnlineUserList(onlineUserList)));
return;
}
onlineUserList.Clear();
foreach (var user in Main.ludo.Users)
{
onlineUserList.Items.Add(user.UserName);
}
onlineUserList.Items[ClientBase.myUserListIndex].BackColor = System.Drawing.Color.Gold; // Set this user background color
}
示例6: createListView
public void createListView(ListView listView, String responseDate, String responseString)
{
// Add the group, using the date for the response data as the group name.
ListViewGroup responseDateGroup = new ListViewGroup (responseDate);
listView.Groups.Add (responseDateGroup);
// This ensures that each entry is put on a separate line.
listView.AutoResizeColumns (ColumnHeaderAutoResizeStyle.ColumnContent);
// Without clearing the listview first, duplicate elements will appear.
if (listView.Groups.Count == 1)
{
listView.Clear ();
}
// Display each response on a separate line.
ListViewItem responseStringItem;
String[] responses = responseString.Split ('\n');
foreach (string word in responses)
{
responseStringItem = new ListViewItem (word, responseDateGroup);
listView.Items.Add (responseStringItem);
}
}
示例7: BindResultSet
public static void BindResultSet(ResultSet resultSet, ListView listView) {
listView.BeginUpdate();
try {
listView.Clear();
listView.Columns.Add("No");
foreach(var name in resultSet.FieldNames)
listView.Columns.Add(name);
var i = 0;
foreach(var row in resultSet) {
var item = new ListViewItem(i.ToString());
foreach(var name in resultSet.FieldNames)
item.SubItems.Add(row[name].AsText());
listView.Items.Add(item);
i++;
}
}
finally {
listView.EndUpdate();
}
}
示例8: FillDataBaseStatusToList
/// <summary>
/// Fill Database status to ListView
/// </summary>
/// <param name="lstSvr"></param>
public static void FillDataBaseStatusToList(ListView lstSvr)
{
lstSvr.Clear();
if (SystemManager.IsUseDefaultLanguage())
{
lstSvr.Columns.Add("DataBaseName");
lstSvr.Columns.Add("CollectionCount");
lstSvr.Columns.Add("DataSize");
lstSvr.Columns.Add("FileSize");
lstSvr.Columns.Add("IndexCount");
lstSvr.Columns.Add("IndexSize");
lstSvr.Columns.Add("ObjectCount");
lstSvr.Columns.Add("StorageSize");
}
else
{
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_DataBaseName));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_CollectionCount));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_DataSize));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_FileSize));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_IndexCount));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_IndexSize));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_ObjectCount));
lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_StorageSize));
}
foreach (String mongoSvrKey in _mongoConnSvrLst.Keys)
{
try
{
MongoServer mongoSvr = _mongoConnSvrLst[mongoSvrKey];
//感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
if (!SystemManager.GetCurrentServerConfig(mongoSvrKey).Health ||
!SystemManager.GetCurrentServerConfig(mongoSvrKey).LoginAsAdmin) { continue; }
List<String> databaseNameList = mongoSvr.GetDatabaseNames().ToList<String>();
foreach (String strDBName in databaseNameList)
{
MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
DatabaseStatsResult dbStatus = mongoDB.GetStats();
ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
try
{
lst.SubItems.Add(dbStatus.CollectionCount.ToString());
}
catch (Exception)
{
lst.SubItems.Add("0");
}
lst.SubItems.Add(GetSize(dbStatus.DataSize));
lst.SubItems.Add(GetSize(dbStatus.FileSize));
lst.SubItems.Add(dbStatus.IndexCount.ToString());
lst.SubItems.Add(GetSize(dbStatus.IndexSize));
lst.SubItems.Add(dbStatus.ObjectCount.ToString());
lst.SubItems.Add(GetSize(dbStatus.StorageSize));
lstSvr.Items.Add(lst);
}
}
catch (Exception ex)
{
throw ex;
}
}
}
示例9: UpdateFriendListView
private void UpdateFriendListView(ListView listview ,List<InboxUser> user, bool showNewMessage = false)
{
try
{
listview.Clear();
ImageList il = new ImageList();
il.TransparentColor = Color.Blue;
il.ColorDepth = ColorDepth.Depth32Bit;
il.ImageSize = new Size(50, 50);
for (int i = 0; i < user.Count; i++)
{
il.Images.Add(Image.FromFile(user[i].ProfilePath));
il.Images.SetKeyName(i, user[i].UserName);
}
listview.View = View.LargeIcon;
//listview.LargeImageList = il;
listview.Invoke(new Action(()=>listview.LargeImageList = il));
for (int j = 0; j < user.Count; j++)
{
ListViewItem item = new ListViewItem();
if (showNewMessage)
{
item.Text = GetInboxText(il.Images.Keys[j].ToString(), user[j].CountNew);
UpdateNewMessageLabel(null, lbReceiverNewMessage, user[j]);
}
else
{
item.Text = il.Images.Keys[j].ToString();
}
item.Name = user[j].UserID;
item.ImageIndex = j;
// listview.Items.Add(item);
listview.Invoke(new Action(()=>listview.Items.Add(item)));
}
}
catch (Exception e)
{
Form1.Log(e);
}
}
示例10: FillSrvStatusToList
/// <summary>
/// 将服务器状态放入ListView
/// </summary>
/// <param name="lstSvr"></param>
public static void FillSrvStatusToList(ListView lstSvr)
{
lstSvr.Clear();
lstSvr.Columns.Add("名称");
lstSvr.Columns.Add("数据集数量");
lstSvr.Columns.Add("数据大小");
lstSvr.Columns.Add("文件大小");
lstSvr.Columns.Add("索引数量");
lstSvr.Columns.Add("索引数量大小");
lstSvr.Columns.Add("对象数量");
lstSvr.Columns.Add("占用大小");
foreach (String mongoSvrKey in _mongoSrvLst.Keys)
{
try
{
MongoServer mongoSvr = _mongoSrvLst[mongoSvrKey];
List<string> databaseNameList = mongoSvr.GetDatabaseNames().ToList<string>();
foreach (String strDBName in databaseNameList)
{
MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
DatabaseStatsResult dbStatus = mongoDB.GetStats();
ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
try
{
lst.SubItems.Add(dbStatus.CollectionCount.ToString());
}
catch (Exception)
{
lst.SubItems.Add(string.Empty);
}
lst.SubItems.Add(GetSize(dbStatus.DataSize));
lst.SubItems.Add(GetSize(dbStatus.FileSize));
lst.SubItems.Add(dbStatus.IndexCount.ToString());
lst.SubItems.Add(GetSize(dbStatus.IndexSize));
lst.SubItems.Add(dbStatus.ObjectCount.ToString());
lst.SubItems.Add(GetSize(dbStatus.StorageSize));
lstSvr.Items.Add(lst);
}
}
catch (Exception)
{
//throw;
}
}
}
示例11: FillDBStatusToList
/// <summary>
/// 将DB状态放入ListView
/// </summary>
/// <param name="lstData"></param>
public static void FillDBStatusToList(ListView lstData)
{
lstData.Clear();
lstData.Columns.Add("名称");
lstData.Columns.Add("文档数量");
lstData.Columns.Add("实际大小");
lstData.Columns.Add("占用大小");
lstData.Columns.Add("索引");
lstData.Columns.Add("平均对象大小");
lstData.Columns.Add("填充因子");
foreach (String mongoSvrKey in _mongoSrvLst.Keys)
{
try
{
MongoServer mongoSvr = _mongoSrvLst[mongoSvrKey];
List<string> databaseNameList = mongoSvr.GetDatabaseNames().ToList<string>();
foreach (string strDBName in databaseNameList)
{
MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
List<string> colNameList = mongoDB.GetCollectionNames().ToList<string>();
foreach (string strColName in colNameList)
{
CollectionStatsResult dbStatus = mongoDB.GetCollection(strColName).GetStats();
ListViewItem lst = new ListViewItem(strDBName + "." + strColName);
lst.SubItems.Add(dbStatus.ObjectCount.ToString());
lst.SubItems.Add(GetSize(dbStatus.DataSize));
lst.SubItems.Add(GetSize(dbStatus.StorageSize));
lst.SubItems.Add(GetSize(dbStatus.TotalIndexSize));
try
{
//在某些条件下,这个值会抛出异常,IndexKeyNotFound
lst.SubItems.Add(GetSize((long)dbStatus.AverageObjectSize));
}
catch (Exception)
{
lst.SubItems.Add("-");
}
try
{
//在某些条件下,这个值会抛出异常,IndexKeyNotFound
lst.SubItems.Add(dbStatus.PaddingFactor.ToString());
}
catch (Exception)
{
lst.SubItems.Add("-");
}
lstData.Items.Add(lst);
}
}
}
catch (Exception)
{
//throw;
}
}
}
示例12: SetUserListToListView
/// <summary>
/// 用户列表
/// </summary>
/// <param name="dataList"></param>
/// <param name="lstData"></param>
private static void SetUserListToListView(List<BsonDocument> dataList, ListView lstData)
{
lstData.Clear();
lstData.Columns.Add("ID");
lstData.Columns.Add("用户名");
lstData.Columns.Add("是否只读");
//密码是密文表示的,这里没有安全隐患
lstData.Columns.Add("密码");
foreach (BsonDocument docFile in dataList)
{
ListViewItem lstItem = new ListViewItem();
lstItem.Text = docFile.GetValue("_id").ToString();
lstItem.SubItems.Add(docFile.GetValue("user").ToString());
lstItem.SubItems.Add(docFile.GetValue("readOnly").ToString());
lstItem.SubItems.Add(docFile.GetValue("pwd").ToString());
lstData.Items.Add(lstItem);
}
}
示例13: SetUserListToListView
/// <summary>
/// 用户列表
/// </summary>
/// <param name="dataList"></param>
/// <param name="lstData"></param>
private static void SetUserListToListView(List<BsonDocument> dataList, ListView lstData)
{
//2.4以后的用户,没有ReadOnly属性,取而代之的是roles属性
//这里为了向前兼容暂时保持ReadOnle属性
//Ref:http://docs.mongodb.org/manual/reference/method/db.addUser/
lstData.Clear();
if (!SystemManager.IsUseDefaultLanguage)
{
lstData.Columns.Add("ID");
lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Username));
lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Roles));
lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Password));
lstData.Columns.Add("userSource");
lstData.Columns.Add("otherDBRoles");
lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_ReadOnly));
}
else
{
lstData.Columns.Add("ID");
lstData.Columns.Add("user");
lstData.Columns.Add("roles");
lstData.Columns.Add("password");
lstData.Columns.Add("userSource");
lstData.Columns.Add("otherDBRoles");
lstData.Columns.Add("readonly");
}
foreach (BsonDocument docFile in dataList)
{
ListViewItem lstItem = new ListViewItem();
//ID
lstItem.Text = docFile.GetValue(KEY_ID).ToString();
//User
lstItem.SubItems.Add(docFile.GetValue("user").ToString());
//roles
BsonValue strRoles;
docFile.TryGetValue("roles", out strRoles);
if (strRoles == null)
{
lstItem.SubItems.Add("N/A");
}
else
{
lstItem.SubItems.Add(strRoles.ToString());
}
//密码是Hash表示的,这里没有安全隐患
//Password和userSource不能同时设置,所以password也可能不存在
BsonValue strPassword;
docFile.TryGetValue("pwd", out strPassword);
if (strPassword == null)
{
lstItem.SubItems.Add("N/A");
}
else
{
lstItem.SubItems.Add(strPassword.ToString());
}
//userSource
BsonValue strUserSource;
docFile.TryGetValue("userSource", out strUserSource);
if (strUserSource == null)
{
lstItem.SubItems.Add("N/A");
}
else
{
lstItem.SubItems.Add(strUserSource.ToString());
}
//OtherDBRoles
BsonValue strOtherDBRoles;
docFile.TryGetValue("otherDBRoles", out strOtherDBRoles);
if (strOtherDBRoles == null)
{
lstItem.SubItems.Add("N/A");
}
else
{
lstItem.SubItems.Add(strOtherDBRoles.ToString());
}
//ReadOnly
//20130802 roles列表示。ReadOnly可能不存在!
BsonValue strReadOnly;
docFile.TryGetValue("readOnly", out strReadOnly);
if (strReadOnly == null)
{
lstItem.SubItems.Add("N/A");
}
else
{
lstItem.SubItems.Add(strReadOnly.ToString());
}
lstData.Items.Add(lstItem);
}
lstData.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
}
示例14: ShowJsonItemData
public void ShowJsonItemData(ListView listView)
{
listView.Clear();
BuildJsonItemDataList(listView, m_JsonCollection);
}
示例15: fillCollumn
private int fillCollumn(ListView.ListViewItemCollection items, string tableName,bool type)
{
bool flag = true;
int counter = 0;
if (type)
items.Clear();
List<object[]> fstDBNERows = new List<object[]> { };
List<object[]> sndDBNERows = new List<object[]> { };
List<ListViewItem> tItems = new List<ListViewItem> { };
List<int> sI= new List<int> { };
if (!flags.ContainsKey(tableName))
flags.Add(tableName, new List<int> { });
if (type)
if (sTableChange)
{
if (selectedTableIndex != null)
clearColumnsCheckers();
createColumnsCheckers(tableName);
selectedTableIndex = comboBox1.SelectedText;
}
if (type)
sI = flags[tableName];
SQLiteConnection fstDBConnection = new SQLiteConnection("Data Source=" + fstFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;");
fstDBConnection.Open();
SQLiteCommand read = new SQLiteCommand("SELECT * FROM " + tableName);
read.Connection = fstDBConnection;
SQLiteDataReader fstDBReader = read.ExecuteReader();
SQLiteConnection sndDBConnection = new SQLiteConnection("Data Source=" + sndFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;");
sndDBConnection.Open();
SQLiteCommand sndRead = new SQLiteCommand("SELECT * FROM " + tableName);
sndRead.Connection = sndDBConnection;
SQLiteDataReader sndDBReader = sndRead.ExecuteReader();
while (sndDBReader.Read())
{
object[] tmp = new object[sndDBReader.FieldCount];
for (int i = 0; i < tmp.Length; i++)
if (!sndDBReader.IsDBNull(i))
if (sndDBReader.GetFieldType(i) != typeof(DateTime))
tmp[i] = sndDBReader.GetValue(i);
else
{
tmp[i] = sndDBReader.GetString(i);
}
else
tmp[i] = "null";
sndDBNERows.Add(tmp);
}
while (fstDBReader.Read())
{
object[] row = new object[fstDBReader.FieldCount];
for (int i = 0; i < row.Length; i++)
if (!fstDBReader.IsDBNull(i))
if (fstDBReader.GetFieldType(i) != typeof(DateTime))
row[i] = fstDBReader.GetValue(i);
else
{
row[i] = fstDBReader.GetString(i);
}
else
row[i] = "null";
if (!addEqRowInList(row, sndDBNERows, tItems, sI, type))
fstDBNERows.Add(row);
}
for (int i = 0; i < sndDBNERows.Count;i++ )
if (addEqRowInList(sndDBNERows[i], fstDBNERows, tItems, sI, type))
sndDBNERows.RemoveAt(i);
while (fstDBNERows.Count != 0 && sndDBNERows.Count != 0)
{
if (fstDBNERows.Count == 0)
{
foreach (object[] row in sndDBNERows)
if (type)
addRow2List(null, row, tItems, 1, sI, null);
sndDBNERows.Clear();
counter += sndDBNERows.Count;
}
else if (sndDBNERows.Count == 0)
{
foreach (object[] row in fstDBNERows)
if (type)
addRow2List(row, null, tItems, 1, sI, null);
fstDBNERows.Clear();
counter += fstDBNERows.Count;
}
else
for (int i = 0; i < fstDBNERows.Count; i++)
{
List<int> count = new List<int> { };
//.........这里部分代码省略.........