惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
V
V2EX
IT之家
IT之家
J
Java Code Geeks
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
D
Docker
S
Secure Thoughts
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
博客园_首页
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
I
InfoQ
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
W
WeLiveSecurity
T
Troy Hunt's Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Scott Helme
Scott Helme
T
Tor Project blog
Know Your Adversary
Know Your Adversary
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
G
Google Developers Blog

博客园 - jdmei520

2D纹理与3D模型共存时的渲染问题 Adventure Works示例数据库介绍 基于 SOA 的监测、诊断与预测系统架构 基于SOA的设备智能维护系统架构设计及实现 WCF基础知识问与答 (转载) 学习资源 Wcf概述 用Visual C#创建Windows服务程序 VS2005没有源代码管理选项和菜单 - jdmei520 - 博客园 RFID射频识别技术 微软RFID开发平台BizTalk资料收集 未能建立与LOCAL的连接——Telnet成功,这就说明是你自己造成的 TextBox 绑定表的数字类型字段,清除文本框内容时,焦点不能移出文本框的解决方法 - jdmei520 - 博客园 使用NUnit在.Net编程中进行单元测试 Enterprise Library 企业库 控制图纸多线相交交点凸起(Control PolyLine Bulge open and close ) 常用数据库访问接口 广州日报新媒体发展战略解析(转) 如何编程控制动态块的参数、动作
ListView控件(在ListView失去焦点的情况下仍然保持Item高亮)
jdmei520 · 2010-03-16 · via 博客园 - jdmei520

 ListView控件(在ListView失去焦点的情况下仍然保持Item高亮)
 
添加列:
在“属性”窗口中,将该控件的 View 属性设置为 Details。

在“属性”窗口中,单击 Columns 属性旁的“省略号”按钮 ()。

出现“ColumnHeader 集合编辑器”。

使用“添加”按钮添加新列。然后可以选择列标题并设置其文本(列的标题文字)、文本对齐方式和宽度。

代码

        private void button2_Click(object sender, EventArgs e)
        {
            
if (listView1.SelectedItems.Count > 0)
                MessageBox.Show(listView1.SelectedItems[
0].Text);
            
else
                MessageBox.Show(
"请选择"); 
        }
private void ListviewDemo_Load(object sender, EventArgs e)
        {
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "A""a" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "B""b" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "C""c" }));
            listView1.Items.Add(
new ListViewItem(new string[] { "D""d" }));
        }
private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            listView1.Items.Add(
new ListViewItem(new string[] { "添加""添加" }));
        }
private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            MessageBox.Show(
"删除" + listView1.SelectedItems[0].Text);
            listView1.SelectedItems[
0].Remove();
        }
#region  在ListView失去焦点的情况下仍然保持Item高亮
        
private void listView_Validated(object sender, EventArgs e)
        {
            
if (listView1.FocusedItem != null)
            {
                listView1.FocusedItem.BackColor 
= SystemColors.Highlight;
                listView1.FocusedItem.ForeColor 
= Color.White;
                listView1.SelectedIndices.Add(listView1.FocusedItem.Index);
//**真正让其选择
            }
        }
private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            e.Item.ForeColor 
= Color.Black;
            e.Item.BackColor 
= SystemColors.Window;if (listView1.FocusedItem != null)
            {
                listView1.FocusedItem.Selected 
= true;
            }
        }
        
#endregion