资源简介
使用VS2015 C# 编写的listview程序,可实现单元格的编写,其中代码在其他版本也可运行
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Listviewedit
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(1 20);
listView1.SmallImageList = imgList;
listView1.BackColor = Color.DarkGray;
txtEdit.KeyDown += new KeyEventHandler(txtEdit_KeyDown);
}
private void txtEdit_KeyDown(object sender KeyEventArgs e)
{
//Enter键 更新项并隐藏编辑框
Point tmpPoint = listView1.PointToClient(Cursor.Position);
ListViewItem.ListViewSubItem subitem = listView1.HitTest(tmpPoint).SubItem;
if (e.KeyCode == Keys.Enter)
{
subitem.Text = txtEdit.Text;
txtEdit.Visible = false;
}
//Esc键 直接隐藏编辑框
if (e.KeyCode == Keys.Escape)
txtEdit.Visible = false;
}
private void listView1_MouseClick(object sender MouseEventArgs e)
{
txtEdit.Visible = false;
}
private void listView1_MouseDoubleClick(object sender MouseEventArgs e)
{
string itemText = ““;
ListViewItem lvi = listView1.GetItemAt(e.X e.Y);
ListViewItem.ListViewSubItem lvsi = lvi.GetSubItemAt(e.X e.Y);
int colIndex = lvi.SubItems.IndexOf(lvsi);
if (lvi != null && colIndex >= 0)
{
itemText = listView1.Columns[colIndex].Text;
Rectangle rect = lvi.GetBounds(ItemBoundsPortion.Entire);
for(int i = 0;i< colIndex;i++)
{
rect.X += listView1.Columns[i].Width;
}
rect.Width = listView1.Columns[colIndex].Width;
txtEdit.Parent = listView1;
txtEdit.Bounds = rect;
txtEdit.Multiline = true;
txtEdit.Visible = true;
txtEdit.Text = itemText;
txtEdit.Focus();
txtEdit.SelectAll();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 41984 2018-06-26 13:43 list\Listviewedit\.vs\Listviewedit\v14\.suo
文件 189 2018-06-26 13:06 list\Listviewedit\Listviewedit\App.config
文件 10752 2018-06-26 13:43 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.exe
文件 189 2018-06-26 13:06 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.exe.config
文件 22016 2018-06-26 13:43 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.pdb
文件 22696 2018-06-26 13:43 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.vshost.exe
文件 189 2018-06-26 13:06 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.vshost.exe.config
文件 490 2017-09-29 21:43 list\Listviewedit\Listviewedit\bin\Debug\Listviewedit.vshost.exe.manifest
文件 2559 2018-06-26 13:43 list\Listviewedit\Listviewedit\Form1.cs
文件 4902 2018-06-26 13:32 list\Listviewedit\Listviewedit\Form1.Designer.cs
文件 5817 2018-06-26 13:32 list\Listviewedit\Listviewedit\Form1.resx
文件 3922 2018-06-26 13:09 list\Listviewedit\Listviewedit\Listviewedit.csproj
文件 868 2018-06-26 13:06 list\Listviewedit\Listviewedit\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7132 2018-06-26 13:06 list\Listviewedit\Listviewedit\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 568 2018-06-26 13:43 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.csproj.FileListAbsolute.txt
文件 1012 2018-06-26 13:32 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.csproj.GenerateResource.Cache
文件 10752 2018-06-26 13:43 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.exe
文件 180 2018-06-26 13:32 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.Form1.resources
文件 22016 2018-06-26 13:43 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.pdb
文件 180 2018-06-26 13:09 list\Listviewedit\Listviewedit\obj\Debug\Listviewedit.Properties.Resources.resources
文件 0 2018-06-26 13:06 list\Listviewedit\Listviewedit\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2018-06-26 13:06 list\Listviewedit\Listviewedit\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2018-06-26 13:06 list\Listviewedit\Listviewedit\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 524 2018-06-26 13:06 list\Listviewedit\Listviewedit\Program.cs
文件 1332 2018-06-26 13:06 list\Listviewedit\Listviewedit\Properties\AssemblyInfo.cs
文件 2837 2018-06-26 13:06 list\Listviewedit\Listviewedit\Properties\Resources.Designer.cs
文件 5612 2018-06-26 13:06 list\Listviewedit\Listviewedit\Properties\Resources.resx
文件 1099 2018-06-26 13:06 list\Listviewedit\Listviewedit\Properties\Settings.Designer.cs
文件 249 2018-06-26 13:06 list\Listviewedit\Listviewedit\Properties\Settings.settings
文件 1003 2018-06-26 13:06 list\Listviewedit\Listviewedit.sln
............此处省略15个文件信息
相关资源
- c#读取外部程序 SysListView32、ListView2
- C#的ListView在VirtualMode模式下带CheckBo
- C#取得SysListView32所有行(包括列表头
- 自定义的ListView(C#) 可以在任意列
- C#ListView控件使用简单源代码
- (c#)使用SHGetFileInfo获取文件或文件
- C#listview双击修改源码4个版本
- WPF操作滚动条
- WPF3D转圈与鼠标拖动图片移动 listvie
- C# ListView中添加ComboBox等控件
- 树形列表控件CSharp,WinForm
- C# ListView中添加多种自定义控件源码
- C# winform ListView 中实现可编辑文本或双
- C# 三层架构实现DataGridView与Listview的增
- C# WinForm TreeListView控件用法
- C# 系统应用之TreeView控件显示树状磁盘
- C# WinForm ListView控件的美化效果
- C# listview大合集,里面绝对有一款是你
- C# Listview 基本用法源码案例
- ListView控件间的数据移动
- WpfApplication1 一个很好的示例
- ImageListViewSource C# winform中图片列表控
- WPF中listview显示列表的删除和显示
- WPF TreeView ListView 数据联动
- WPF ListView 选择和鼠标移上去行背景颜
- C# Winform ListView添加按钮列
- WPF 下拉列表框ComboBox扩展控件
- c#,windows Api读取其他程序SysListview3
- WPF安装压缩包
- C#利用ListView控件显示数据库数据
评论
共有 条评论