和墨C#根据文件扩展名显示相应的图标问题 我用的是VS.NET2005,我现在从数据库中获取文件的名字和文件的扩展名,如何根据文件的扩展名在TreeView中显示出来相应的文件图标,请各位给个思路,我找了很久都没有思路,希望各位大侠给小弟详细的讲一下,谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵……听说上次Sunmast搞这个搞到抓狂。 无论winform还是webform,思路都是一样的以下是webform下的做法1)switch (ext.ToLower()) { case "txt": currentTreeNode.ImageUrl = "images/ext_txt.gif"; break; case "gif": currentTreeNode.ImageUrl = "images/ext_gif.gif"; break; ...}2)Dictionary<string, string> extImgs = new Dictionary<string, string> (StringComparer.InvariantCultureIgnoreCase);extImgs.Add("txt", "images/ext_txt.gif");......----------------------------string extImg;if (extImgs.TryGetValue(ext, out extImg)) currentTreeNode.ImageUrl = extImg;winform下要用ImageList,如果用.NET 2.0,可以用字符串做Key,这样就很像上面的(2)了否则,还要自定义一个string->int的映射要么hashtable,要么switch()case SplitterDistance 必须在 Panel1MinSize 和 Width - Panel2MinSize 之间 C# 问串口问题() 60分跪求:Asp.net 网站打包问题! %5F编码问题 怎样使用C#来封装文件 多个摄像头同时显示的程序,C#实现? 泛型使用报错:未将对象引用设置到对象的实例!望高手请进! [请教、求助]关于分页的问题 变量类型转换的问题/ 日期字段如何查询? 如何从剪切板获取一个OLE对象(OLE对象已经复制到剪切板了) 请问一个关于流式套接字的问题?
switch (ext.ToLower()) {
case "txt":
currentTreeNode.ImageUrl = "images/ext_txt.gif";
break;
case "gif":
currentTreeNode.ImageUrl = "images/ext_gif.gif";
break;
...
}2)
Dictionary<string, string> extImgs = new Dictionary<string, string>
(StringComparer.InvariantCultureIgnoreCase);
extImgs.Add("txt", "images/ext_txt.gif");
......----------------------------
string extImg;
if (extImgs.TryGetValue(ext, out extImg))
currentTreeNode.ImageUrl = extImg;
winform下要用ImageList,如果用.NET 2.0,可以用字符串做Key,这样就很像上面的(2)了
否则,还要自定义一个string->int的映射
要么hashtable,要么switch()case