本文整理汇总了C#中ListViewItem类的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem类的具体用法?C# ListViewItem怎么用?C# ListViewItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListViewItem类属于命名空间,在下文中一共展示了ListViewItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HelloForm
public HelloForm()
{
this.Text = "Hello Form";
this.StartPosition = FormStartPosition.CenterScreen;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.ControlBox = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.BackColor = Color.Red;
lv = new ListView();
lv.Bounds = new Rectangle(new Point(10, 10), new Size(230, 200));
lv.View = View.Details;
lv.CheckBoxes = true;
lv.GridLines = true;
lv.Columns.Add("Column 1", -2, HorizontalAlignment.Left);
lv.Columns.Add("Column 2", -2, HorizontalAlignment.Left);
lv.Columns.Add("Column 3", -2, HorizontalAlignment.Left);
lv.Columns.Add("Column 4", -2, HorizontalAlignment.Center);
ListViewItem item1 = new ListViewItem("name", 0);
item1.Checked = true;
item1.SubItems.Add("1");
item1.SubItems.Add("2");
item1.SubItems.Add("3");
lv.Items.Add(item1);
this.Controls.Add(lv);
}
示例2: RssGetting
private void RssGetting()
{
string rssAddress = "http://www.lzbt.net/rss.php";//RSS地址
XmlDocument doc = new XmlDocument();//创建文档对象
try
{
doc.Load(rssAddress);//加载XML 包括 HTTP:// 和本地
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);//异常处理
}
XmlNodeList list = doc.GetElementsByTagName("item"); //获得项
foreach (XmlNode node in list) //循环每一项
{
XmlElement ele = (XmlElement)node;
//添加到列表内
ListViewItem item = new ListViewItem();
item.Content=ele.GetElementsByTagName("title")[0].InnerText;//获得标题
item.Tag = ele.GetElementsByTagName("link")[0].InnerText;//获得联接
mainRssList.Items.Add(item);
//添加结束
}
}
示例3: adicionarProdutosNaLista
private void adicionarProdutosNaLista(List<Pedido> pedidosNaoPagos)
{
this.lstListaDePedidos.Items.Clear();
foreach (Pedido pedido in pedidosNaoPagos) {
// 1. Adicionar o titulo do pedido
ListViewItem listViewItemTituloPedido = new ListViewItem()
{
//Text = String.Format("{0} - ({1})", pedido.Id.ToString(), pedido.HorarioEntrada),
Text = String.Format("[{0}]", pedido.HorarioEntrada),
Name = pedido.Id.ToString(),
Selected = true
};
this.lstListaDePedidos.Items.Add(listViewItemTituloPedido);
// Adicionar produtos do pedido
foreach (ItemPedido item in pedido.ItensPedidos) {
ListViewItem listViewItem = new ListViewItem()
{
Text = "-> " + item.Produto.Nome
};
listViewItem.SubItems.Add(item.QtdProduto.ToString());
listViewItem.SubItems.Add(item.Valor.ToString("C"));
this.lstListaDePedidos.Items.Add(listViewItem);
}
}
this.txtValorTotalConta.Text = pedidosNaoPagos.Sum(p => p.ValorPedido).ToString("C");
}
示例4: ListViewExam
public ListViewExam()
{
this.Text = "ListView 예제";
ListView lst = new ListView();
lst.Parent = this;
lst.Dock = DockStyle.Fill;
lst.View = View.Details; // 컬럼 정보가 출력
// 컬럼 해더 추가
lst.Columns.Add("국가", 70, HorizontalAlignment.Left);
lst.Columns.Add("수도", 70, HorizontalAlignment.Center);
lst.Columns.Add("대륙", 70, HorizontalAlignment.Right);
// 데이터 추가
ListViewItem lvi_korea = new ListViewItem("대한민국");
lvi_korea.SubItems.Add("서울");
lvi_korea.SubItems.Add("아시아");
ListViewItem lvi_canada = new ListViewItem("캐나다");
lvi_canada.SubItems.Add("오타와");
lvi_canada.SubItems.Add("아메리카");
ListViewItem lvi_france = new ListViewItem("프랑스");
lvi_france.SubItems.Add("파리");
lvi_france.SubItems.Add("유럽");
lst.Items.Add(lvi_korea);
lst.Items.Add(lvi_canada);
lst.Items.Add(lvi_france);
}
示例5: PercentageView
public PercentageView(BiorhythmCalculator calculator)
{
this.calculator = calculator;
calculator.Updated += new EventHandler(OnCalculatorUpdate);
this.Title.Text = calculator.CurrentDate.ToShortDateString();
birthDateListItem = new ListViewItem();
daysOldListItem = new ListViewItem();
physicalListItem = new ListViewItem();
emotionalListItem = new ListViewItem();
intellectualListItem = new ListViewItem();
OnCalculatorUpdate(this, EventArgs.Empty);
birthDateListItem.Description = "Your birthdate, tap to set";
this.Items.Add(birthDateListItem);
this.Items.Add(daysOldListItem);
this.Items.Add(physicalListItem);
this.Items.Add(emotionalListItem);
this.Items.Add(intellectualListItem);
this.Click += new EventHandler(OnClick);
}
示例6: cmdGet_Click
private void cmdGet_Click(object sender, EventArgs e)
{
try
{
//execute the GetRssFeeds method in out
//FeedManager class to retrieve the feeds
//for the specified URL
reader.Url = txtURL.Text;
reader.getFeed();
list = reader.rssItems;
//list = reader
//now populate out ListBox
//loop through the count of feed items returned
for (int i = 0; i < list.Count; i++)
{
//add the title, link and public date
//of each feed item to the ListBox
row = new ListViewItem();
row.Text = list[i].Title;
row.SubItems.Add(list[i].Link);
row.SubItems.Add(list[i].Date.ToShortDateString());
lstNews.Items.Add(row);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
示例7: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
int paramLength = this.Intent.GetIntExtra (AlarmClock.ExtraLength, 0);
if (Log.IsLoggable (Tag, LogPriority.Debug))
Log.Debug (Tag, "SetTimerActivity:onCreate=" + paramLength);
if (paramLength > 0 && paramLength <= 86400) {
long durationMillis = paramLength * 1000;
SetupTimer (durationMillis);
Finish ();
return;
}
var res = this.Resources;
for (int i = 0; i < NumberOfTimes; i++) {
timeOptions [i] = new ListViewItem (
res.GetQuantityString (Resource.Plurals.timer_minutes, i + 1, i + 1),
(i + 1) * 60 * 1000);
}
SetContentView (Resource.Layout.timer_set_timer);
// Initialize a simple list of countdown time options.
wearableListView = FindViewById<WearableListView> (Resource.Id.times_list_view);
wearableListView.SetAdapter (new TimerWearableListViewAdapter (this));
wearableListView.SetClickListener (this);
}
示例8: ListViewCommandEventArgs
public ListViewCommandEventArgs(ListViewItem item, object commandSource, CommandEventArgs originalArgs)
: base(originalArgs)
{
_item = item;
_commandSource = commandSource;
string cmdName = originalArgs.CommandName;
if (String.Compare(cmdName, ListView.SelectCommandName, true, CultureInfo.InvariantCulture) == 0) {
_commandType = ListViewCommandType.Select;
}
else if (String.Compare(cmdName, ListView.EditCommandName, true, CultureInfo.InvariantCulture) == 0) {
_commandType = ListViewCommandType.Edit;
}
else if (String.Compare(cmdName, ListView.UpdateCommandName, true, CultureInfo.InvariantCulture) == 0) {
_commandType = ListViewCommandType.Update;
}
else if (String.Compare(cmdName, ListView.CancelEditCommandName, true, CultureInfo.InvariantCulture) == 0) {
_commandType = ListViewCommandType.CancelEdit;
}
else if (String.Compare(cmdName, ListView.DeleteCommandName, true, CultureInfo.InvariantCulture) == 0) {
_commandType = ListViewCommandType.Delete;
}
else {
_commandType = ListViewCommandType.Custom;
}
}
示例9: AddItem
public void AddItem(ListViewItem Item)
{
if (ItemAdded != null)
{
ItemAdded(Item);
}
base.Items.Add(Item);
}
示例10: RemoveItem
public void RemoveItem(ListViewItem Item)
{
if (ItemRemoved != null)
{
ItemRemoved();
}
base.Items.Remove(Item);
}
示例11: MainForm
public MainForm ()
{
ListViewItem listViewItem1 = new ListViewItem (new string [] {
"de Icaza",
"Miguel",
"Somewhere"}, -1);
SuspendLayout ();
//
// _listView
//
_listView = new ListView ();
_listView.Dock = DockStyle.Top;
_listView.FullRowSelect = true;
_listView.Height = 97;
_listView.Items.Add (listViewItem1);
_listView.TabIndex = 0;
_listView.View = View.Details;
Controls.Add (_listView);
//
// _nameHeader
//
_nameHeader = new ColumnHeader ();
_nameHeader.Text = "Name";
_nameHeader.Width = 75;
_listView.Columns.Add (_nameHeader);
//
// _firstNameHeader
//
_firstNameHeader = new ColumnHeader ();
_firstNameHeader.Text = "FirstName";
_firstNameHeader.Width = 77;
_listView.Columns.Add (_firstNameHeader);
//
// _countryHeader
//
_countryHeader = new ColumnHeader ();
_countryHeader.Text = "Country";
_countryHeader.Width = 108;
_listView.Columns.Add (_countryHeader);
//
// _bugDescriptionLabel
//
_bugDescriptionLabel = new Label ();
_bugDescriptionLabel.Location = new Point (8, 110);
_bugDescriptionLabel.Size = new Size (280, 112);
_bugDescriptionLabel.TabIndex = 2;
_bugDescriptionLabel.Text = "The row in the listview should not have a focus rectangle drawn around it.";
Controls.Add (_bugDescriptionLabel);
//
// Form1
//
AutoScaleBaseSize = new Size (5, 13);
ClientSize = new Size (292, 160);
StartPosition = FormStartPosition.CenterScreen;
Text = "bug #79253";
ResumeLayout (false);
}
示例12: MainForm_Load
void MainForm_Load (object sender, EventArgs e)
{
for (int i = 0; i < 200; i++) {
ListViewItem listViewItem = new ListViewItem (new string [] {
"de Icaza",
"Miguel",
"Somewhere"}, 0);
_listView.Items.Add (listViewItem);
}
}
示例13: AddToList
private void AddToList(ListViewItem lvItem)
{
if (this._MCForm.lvErrorCollector.InvokeRequired)
{
AddToListCB d = new AddToListCB(AddToList);
this._MCForm.lvErrorCollector.Invoke(d, new object[] { lvItem });
}
else
{
this._MCForm.lvErrorCollector.Items.Insert(0, lvItem);
}
}
示例14: DiskImageProperies_Load
private void DiskImageProperies_Load(System.Object sender, System.EventArgs e)
{
Hashtable props = _disk.Properties();
ListViewItem li;
foreach (DictionaryEntry de in props)
{
li = new ListViewItem((string)de.Key);
li.SubItems.Add(string.Format("{0}", de.Value));
UIPropList.Items.Add(li);
}
}
示例15: Main
static void Main (string [] args)
{
ListView entryList = new ListView ();
entryList.Sorting = System.Windows.Forms.SortOrder.Descending;
entryList.BeginUpdate ();
entryList.Columns.Add ("Type", 100, HorizontalAlignment.Left);
ListViewItem item = new ListViewItem (new string [] { "A" });
entryList.Items.Add (item);
item = new ListViewItem (new string [] { "B" });
entryList.Items.Add (item);
}