如何获取listview获取item内容里Item中的控件

君,已阅读到文档的结尾了呢~~
【论文】C如何获取任务管理器L..
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
C如何获取任务管理器ListView控件中的内容
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
下载积分:1598
内容提示:Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
文档格式:DOC|
浏览次数:858|
上传日期: 17:35:11|
文档星级:
该用户还上传了这些文档
Android-ListView中嵌套(ListView)控件时item的点击事
官方公共微信ListView子控件点击,如何获取item的值
[问题点数:20分,结帖人u]
ListView子控件点击,如何获取item的值
[问题点数:20分,结帖人u]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。博客访问: 170455
博文数量: 69
博客积分: 2010
博客等级: 大尉
技术积分: 720
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: WINDOWS
如何:向 Windows 窗体 ListView 控件中添加列
// Set to details view.
listView1.View = View.D
// Add a column with width 20 and left alignment.
listView1.Columns.Add("File type", 20, HorizontalAlignment.Left);使用 Windows 窗体 ListView 控件添加和移除项// Adds a new item with ImageIndex 3
listView1.Items.Add("List item text", 3);// Removes the first item in the list.
listView1.Items.RemoveAt(0);
// Clears all the items.
listView1.Items.Clear();如何:向 Windows 窗体 ListView 控件中删除列listView1.Columns.Clear();如何:显示 Windows 窗体 ListView 控件的图标listView1.SmallImageList = imageList1;// Sets the first list item to display the 4th image.
listView1.Items[0].ImageIndex = 3;如何:使用 Windows 窗体 ListView 控件在列中显示子项// Adds two subitems to the first list item.
listView1.Items[0].SubItems.Add("John Smith");
listView1.Items[0].SubItems.Add("Accounting");如何:选择 Windows 窗体 ListView 控件中的项this.listView1.Focus();
this.listView1.Items[0].Selected = true;如何:对 Windows 窗体 ListView 控件中的项进行分组// Adds a new group that has a left-aligned header
listView1.Groups.Add(new ListViewGroup("List item text", _
HorizontalAlignment.Left));如何:在 Windows 窗体 ListView 控件中启用平铺视图listView1.View = View.Tusing S
using System.D
using System.Windows.F
public class ListViewTilingExample : Form
private ImageList myImageL
public ListViewTilingExample()
// Initialize myListView.
ListView myListView = new ListView();
myListView.Dock = DockStyle.F
myListView.View = View.T
// Initialize the tile size.
myListView.TileSize = new Size(400, 45);
// Initialize the item icons.
myImageList = new ImageList();
using (Icon myIcon = new Icon("book.ico"))
myImageList.Images.Add(myIcon);
myImageList.ImageSize = new Size(32, 32);
myListView.LargeImageList = myImageL
// Add column headers so the subitems will appear.
myListView.Columns.AddRange(new ColumnHeader[]
{new ColumnHeader(), new ColumnHeader(), new ColumnHeader()});
// Create items and add them to myListView.
ListViewItem item0 = new ListViewItem( new string[]
{"Programming Windows",
"Petzold, Charles",
"1998"}, 0 );
ListViewItem item1 = new ListViewItem( new string[]
{"Code: The Hidden Language of Computer Hardware and Software",
"Petzold, Charles",
"2000"}, 0 );
ListViewItem item2 = new ListViewItem( new string[]
{"Programming Windows with C#",
"Petzold, Charles",
"2001"}, 0 );
ListViewItem item3 = new ListViewItem( new string[]
{"Coding Techniques for Microsoft Visual Basic .NET",
"Connell, John",
"2001"}, 0 );
ListViewItem item4 = new ListViewItem( new string[]
{"C# for Java Developers",
"Jones, Allen & Freeman, Adam",
"2002"}, 0 );
ListViewItem item5 = new ListViewItem( new string[]
{"Microsoft .NET XML Web Services Step by Step",
"Jones, Allen & Freeman, Adam",
"2002"}, 0 );
myListView.Items.AddRange(
new ListViewItem[] {item0, item1, item2, item3, item4, item5});
// Initialize the form.
this.Controls.Add(myListView);
this.Size = new System.Drawing.Size(430, 330);
this.Text = "ListView Tiling Example";
// Clean up any resources being used.
protected override void Dispose(bool disposing)
if (disposing)
myImageList.Dispose();
base.Dispose(disposing);
[STAThread]
static void Main()
Application.EnableVisualStyles();
Application.Run(new ListViewTilingExample());
}如何:在 Windows 窗体 ListView 控件中显示插入标记using S
using System.D
using System.Windows.F
public class ListViewInsertionMarkExample : Form
private ListView myListV
public ListViewInsertionMarkExample()
// Initialize myListView.
myListView = new ListView();
myListView.Dock = DockStyle.F
myListView.View = View.LargeI
myListView.MultiSelect = false;
myListView.ListViewItemSorter = new ListViewIndexComparer();
// Initialize the insertion mark.
myListView.InsertionMark.Color = Color.G
// Add items to myListView.
myListView.Items.Add("zero");
myListView.Items.Add("one");
myListView.Items.Add("two");
myListView.Items.Add("three");
myListView.Items.Add("four");
myListView.Items.Add("five");
// Initialize the drag-and-drop operation when running
// under Windows XP or a later operating system.
if (OSFeature.Feature.IsPresent(OSFeature.Themes))
myListView.AllowDrop = true;
myListView.ItemDrag += new ItemDragEventHandler(myListView_ItemDrag);
myListView.DragEnter += new DragEventHandler(myListView_DragEnter);
myListView.DragOver += new DragEventHandler(myListView_DragOver);
myListView.DragLeave += new EventHandler(myListView_DragLeave);
myListView.DragDrop += new DragEventHandler(myListView_DragDrop);
// Initialize the form.
this.Text = "ListView Insertion Mark Example";
this.Controls.Add(myListView);
[STAThread]
static void Main()
Application.EnableVisualStyles();
Application.Run(new ListViewInsertionMarkExample());
// Starts the drag-and-drop operation when an item is dragged.
private void myListView_ItemDrag(object sender, ItemDragEventArgs e)
myListView.DoDragDrop(e.Item, DragDropEffects.Move);
// Sets the target drop effect.
private void myListView_DragEnter(object sender, DragEventArgs e)
e.Effect = e.AllowedE
// Moves the insertion mark as the item is dragged.
private void myListView_DragOver(object sender, DragEventArgs e)
// Retrieve the client coordinates of the mouse pointer.
Point targetPoint =
myListView.PointToClient(new Point(e.X, e.Y));
// Retrieve the index of the item closest to the mouse pointer.
int targetIndex = myListView.InsertionMark.NearestIndex(targetPoint);
// Confirm that the mouse pointer is not over the dragged item.
if (targetIndex > -1)
// Determine whether the mouse pointer is to the left or
// the right of the midpoint of the closest item and set
// the InsertionMark.AppearsAfterItem property accordingly.
Rectangle itemBounds = myListView.GetItemRect(targetIndex);
if ( targetPoint.X > itemBounds.Left + (itemBounds.Width / 2) )
myListView.InsertionMark.AppearsAfterItem = true;
myListView.InsertionMark.AppearsAfterItem = false;
// Set the location of the insertion mark. If the mouse is
// over the dragged item, the targetIndex value is -1 and
// the insertion mark disappears.
myListView.InsertionMark.Index = targetI
// Removes the insertion mark when the mouse leaves the control.
private void myListView_DragLeave(object sender, EventArgs e)
myListView.InsertionMark.Index = -1;
// Moves the item to the location of the insertion mark.
private void myListView_DragDrop(object sender, DragEventArgs e)
// Retrieve the index o
int targetIndex = myListView.InsertionMark.I
// If the insertion mark is not visible, exit the method.
if (targetIndex == -1)
// If the insertion mark is to the right of the item with
// the corresponding index, increment the target index.
if (myListView.InsertionMark.AppearsAfterItem)
targetIndex++;
// Retrieve the dragged item.
ListViewItem draggedItem =
(ListViewItem)e.Data.GetData(typeof(ListViewItem));
// Insert a copy of the dragged item at the target index.
// A copy must be inserted before the original item is removed
// to preserve item index values.
myListView.Items.Insert(
targetIndex, (ListViewItem)draggedItem.Clone());
// Remove the original copy of the dragged item.
myListView.Items.Remove(draggedItem);
// Sorts ListViewItem objects by index.
private class ListViewIndexComparer : System.Collections.IComparer
public int Compare(object x, object y)
return ((ListViewItem)x).Index - ((ListViewItem)y).I
}如何:向 ListView 控件添加搜索功能private ListView textListView = new ListView();
private TextBox searchBox = new TextBox();
private void InitializeTextSearchListView()
searchBox.Location = new Point(10, 60);
textListView.Scrollable = true;
textListView.Width = 80;
textListView.Height = 50;
// Set the View to list to use the FindItemWithText method.
textListView.View = View.L
// Populate the ListViewWithItems
textListView.Items.AddRange(new ListViewItem[]{
new ListViewItem("Amy Alberts"),
new ListViewItem("Amy Recker"),
new ListViewItem("Erin Hagens"),
new ListViewItem("Barry Johnson"),
new ListViewItem("Jay Hamlin"),
new ListViewItem("Brian Valentine"),
new ListViewItem("Brian Welker"),
new ListViewItem("Daniel Weisman") });
// Handle the TextChanged to get the text for our search.
searchBox.TextChanged += new EventHandler(searchBox_TextChanged);
// Add the controls to the form.
this.Controls.Add(textListView);
this.Controls.Add(searchBox);
private void searchBox_TextChanged(object sender, EventArgs e)
// Call FindItemWithText with the contents of the textbox.
ListViewItem foundItem =
textListView.FindItemWithText(searchBox.Text, false, 0, true);
if (foundItem != null)
textListView.TopItem = foundI
阅读(3961) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。fragment中添加了button和checkbox这些控件,此时这些子控件会将焦点获取到,所以常常当点击item时变化的是子控件,item本身的点击没有响应。这时候就可以使用descendantFocusability来解决啦,API描述如下::descendantFocusability该属性是当一个为view获取焦点时,定义viewGroup和其子控件两者之间的关系。属性的值有三种:& & & & beforeDescendants:viewgroup会优先其子类控件而获取到焦点& & & & afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点& & & & blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点通常我们用到的是第三种,即在Item布局的根布局加上android:descendantFocusability=”blocksDescendants”的属性。
版权声明:本文为博主原创,未经博主允许不得转载。}

我要回帖

更多关于 listview获取当前item 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信