如何从ListView删除行 [英] How to delete a Row from the ListView
本文介绍了如何从ListView删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我,如何从Listview中删除行...
我在3层尝试了Listview程序..
我在此Delete命令上遇到了错误..
受保护的 无效 ListView1_ItemDeleted(对象发件人,ListViewDeletedEventArgs e)
{
TextBox txtid =(TextBox)ListView1.Items [e.ItemIndex] .FindControl(" );
int EmpId = Convert.ToInt32(txtid.Text);
int i = _objProgram.Delete(EmpId);
如果(i > 0 )
{
Response.Write(" );
}
其他
{
Response.Write(" );
}
}
请解决我的问题并发布答案.
请
解决方案
您可以在下面的代码中进行操作:
ListView1.Items.RemoveAt(i)
u可以尝试此
(ListView1.ListItems.Remove (ListView1.SelectedItem.Index) )
好吧..那就试试这个吧..让我知道...
1 )在表单上,只需拖动一个Listview. 2 )在Listview ' s Items属性中,添加您的弦(放3弦 例如). 3)将Listview的MultiSelect属性设置为False. 4 )在您的Listview ' 的KeyDown事件中,键入: 私人无效listView1_KeyDown(对象发送者,KeyEventArgs e) { 如果(e.KeyCode == Keys.Delete) { listView1.Items.Remove(listView1.FocusedItem); } } 5)运行程序.至少有个项目被选中.继续按 ' Del'(删除)键
>
Please Help me out How to Delete a Row from Listview...
i tried Listview Program in 3-Tier..
I got Error on this Delete command..
protected void ListView1_ItemDeleted(object sender, ListViewDeletedEventArgs e)
{
TextBox txtid = (TextBox)ListView1.Items[e.ItemIndex].FindControl("txtLEmpId");
int EmpId = Convert.ToInt32(txtid.Text);
int i = _objProgram.Delete(EmpId);
if (i > 0)
{
Response.Write("Success");
}
else
{
Response.Write("Fail");
}
}
please Solve my Problem And Post The Ans..
Please
解决方案
you can you below code:
ListView1.Items.RemoveAt(i)
u can try this
(ListView1.ListItems.Remove (ListView1.SelectedItem.Index) )
Ok..try this one then..and let me know...
1) On your form, just drag a Listview. 2) In the Listview's Items property, add your strings (put 3 strings for example). 3) Set the Listview's MultiSelect property to False. 4) In your Listview's KeyDown event, type: private void listView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { listView1.Items.Remove(listView1.FocusedItem); } } 5) Run the program. There's at least one item selected. Keep pressing the 'Del' (Delete) key
这篇关于如何从ListView删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文