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

推荐订阅源

Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
P
Palo Alto Networks Blog
Webroot Blog
Webroot Blog
P
Privacy International News Feed
H
Hacker News: Front Page
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Blog of Author Tim Ferriss
T
Threat Research - Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Schneier on Security
Schneier on Security
Jina AI
Jina AI
Simon Willison's Weblog
Simon Willison's Weblog
Scott Helme
Scott Helme
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
F
Fortinet All Blogs
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
T
Troy Hunt's Blog
MyScale Blog
MyScale Blog
I
InfoQ
F
Full Disclosure
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
Latest news
Latest news
W
WeLiveSecurity
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
N
Netflix TechBlog - Medium
量子位
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
GbyAI
GbyAI
SecWiki News
SecWiki News
AI
AI
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
N
News and Events Feed by Topic
K
Kaspersky official blog
V2EX - 技术
V2EX - 技术

博客园 - 置身珠海,学习与奋斗

【转】WPF获取路径解读 善用Wink,将电脑操作录屏为flash (更新图片) [转]ClickOnce部署出现 系统必备的安装位置未设置为组件供应商的网站,无法在磁盘上找到 dotNetFx40LP_Client_x86_x64cs.exe 问题的解决方案 D60 单反相机拍照后,反光板无法正常弹回,报错的解决办法。 VS 全部补丁包(20100730) 和谐UAC与应用程序配置,抛砖引玉,希望完美解决问题。 论企业信息化的三个阶段:技,术,道 关于ClickOnce在企业内部的应用 中国式管理 Virtual PC 2007 虚拟网络配置 红旗飘扬 关于 Winform 下 ReportViewer 打印异常 咱也写个小写数字转大写金额 ,纯粹字符串操作实现 中国人成功十要 有没有朋友做过动态表结构的,请教一下 自定义app_offline.htm,让网站升级提示更专业 使用PPC的朋友慎用 星空极速3.2.070416_GD 关于89S51单片机数码管显示的小工具 重新启动IIS的小工具
关于ListBox绑定到自定义对象
置身珠海,学习与奋斗 · 2011-03-31 · via 博客园 - 置身珠海,学习与奋斗

总结关键点:

1. ListBox的TextMember与ValueMember必需是属性

2.绑定对象必需继承IList

3. 绑定辅助用这个 private CurrencyManager currencyManager=null;

绑定方法用这个currencyManager = (CurrencyManager)dataGrid1.BindingContext[al];
4.一定要设DataSource属性
5.对象内容发生变化后,要及时刷新 currencyManager.Refresh();

转个链接: http://support.microsoft.com/kb/316303/zh-cn

分步示例

  1. 在 Visual C#.net 或 Visual C# 2005年中创建新的 Windows 应用程序项目。默认情况下创建 Form1。
  2. 将类添加到项目中。
  3. 用下列替换代码中 Class1.cs:

    public class guitar
    {
    	private string make;
    	private string model;
    	private short year;
    	
    	public guitar()
    	{
    	}
    
    	public guitar(string Make, string Model, short Year)
    	{
    	    make=Make;
    	    model=Model;
    	    year=Year;
    	}
    
    	public string Make 
    	{
    		get 
    		{ 
    			return make; 
    		}
    		set 
    		{
    			make = value; 
    		}
    	}
    	
    	public string Model 
    	{
    		get 
    		{ 
    			return model; 
    		}
    		set 
    		{
    			model = value; 
    		}
    	}
    
    	public short Year 
    	{
    		get 
    		{ 
    			return year; 
    		}
    		set 
    		{
    			year = value; 
    		}
    	}
    }
    					

  4. 关闭 Class1.cs 代码窗口,然后切换到窗体设计器。
  5. 向 Form1 中添加一个 DataGrid 控件。调整大小以适应三个行和四个列将 DataGrid 控件。
  6. 将四个 按钮 控件添加到 Form1,然后横向排列按钮。
  7. 下一处 更改 Button1 文本 属性。
  8. 更改到 前一节 的 Button2 文本 属性。
  9. 更改为 第一个 Button3 的 Text 属性。
  10. 上次 更改 Button4 的 Text 属性。
  11. 下面的代码添加到 Form1 类:

    private ArrayList al = new ArrayList();	
    private CurrencyManager currencyManager=null;	
    					

  12. 切换到窗体设计器,用鼠标右键单击该的表单,然后单击 属性
  13. 单击 事件 图标,然后双击 Load 事件将 Form1_Load 事件添加到您的代码。
  14. 将以下代码粘贴到 Form1_Load 事件中:

    al.Add (new guitar("Gibson", "Les Paul", 1958));
    al.Add (new guitar("Fender", "Jazz Bass", 1964));
    al.Add (new guitar("Guild", "Bluesbird", 1971));
    				
    currencyManager = (CurrencyManager)dataGrid1.BindingContext[al];
    	
    dataGrid1.DataSource=al;
    					

  15. 若要查看窗体设计器的开关。
  16. 双击 $ 下一步,然后将下面的代码添加到 button1_Click 事件:

    currencyManager.Position++;
    					

  17. 双击 上一步 中,然后将下面的代码添加到 button2_Click 事件:

    currencyManager.Position--;
    					

  18. 双击 第一个,然后将下面的代码添加到 button3_Click 事件:

    currencyManager.Position = 0;
    					

  19. 双击 最近,然后将下面的代码添加到 button4_Click 事件:

    currencyManager.Position = al.Count - 1;
    					

  20. 生成并运行该项目。
  21. 单击命令按钮以在 DataGrid 控件中的行之间移动。注意是否需要您可以编辑该对象的值。