使用C#从列表框显示的列表视图中添加所选数据 [英] add selected data from listbox show at Listview using c#

查看:79
本文介绍了使用C#从列表框显示的列表视图中添加所选数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

这里正在使用C#Windows应用程序.现在我想在列表视图列中显示从列表框显示中选择的数据.例如,在我的列表框中有一些数据,例如apple,Orange,banana等.我从列表框中选择了Apple,立即将Apple显示在listview列中.我试过,但所有项目都从列表框添加到列表视图中.但我只想添加选定的项目.在此先感谢....

在此先感谢

Dhinesh Kumar.V

Dear All,

Here am working with c# windows application. Now i wanna show selected data from listbox display at listview column. For example in my listbox having some data like apple,Orange,banana etc. It i select apple from listbox, immediately apple displayed at column of listview. i tried but all items from are added to listview from listbox. But i wants to add selected item only. Thanks in Advance....

Thanks in Advance

Dhinesh Kumar.V

推荐答案

hi,

这可能对您检查一次很有用


公共局部类MessageBoxForm:Form
{
...

公共无效LoadListView(ListViewItemCollection项目)
{
orderListView.Clear();
orderListView.AddRange(items);
}
}

....

私人void customerInformationToolStripMenuItem_Click(object sender,EventArgs e)
{
如果(Customers.SelectedItems.Count!= 0)
{
var myformmessagedialog =新的MessageBoxForm
{
名称= Customers.SelectedItems [0] .SubItems [0] .Text,
地址= Customers.SelectedItems [0] .SubItems [3] .Text,
电话= Customers.SelectedItems [0] .SubItems [4] .Text,
};
myformmessagedialog.LoadListView(Customers.Items);
myformmessagedialog.ShowDialog();
}
}


this may be useful for you check it once


public partial class MessageBoxForm : Form
{
...

public void LoadListView(ListViewItemCollection items)
{
orderListView.Clear();
orderListView.AddRange(items);
}
}

....

private void customerInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Customers.SelectedItems.Count != 0)
{
var myformmessagedialog = new MessageBoxForm
{
name = Customers.SelectedItems[0].SubItems[0].Text,
address = Customers.SelectedItems[0].SubItems[3].Text,
telephone = Customers.SelectedItems[0].SubItems[4].Text,
};
myformmessagedialog.LoadListView(Customers.Items);
myformmessagedialog.ShowDialog();
}
}


这篇关于使用C#从列表框显示的列表视图中添加所选数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆