• ToolTip属性:

ToolTip 类
(System.Windows.Controls)‎

表示创建弹出项的控件。该弹出项可显示界面中元素的相关信息。命名空间: System.Windows.Controls 程序集: PresentationFramework

ToolTip 类
(System.Windows.Forms)‎

表示一个长方形的小弹出窗体,该窗体在用户将指针悬停在一个控件上时显示有关该控件用途的简短说明。

以上摘自 MSDN官网。

  • 一般的Label  

其ID能够直接绑定 ToolTip属性,如

DataTable dt = workLogic.GetPersonID(PersonId);
//DataTable dt = new DataTable();
StringBuilder sbName = new StringBuilder();
StringBuilder sbSNO = new StringBuilder();
sbName.Append(dr["USER_CNAME"].ToString().Trim() + ",");
this.labelID.text = sbName;
this.laeblID.ToolTip = sbSNO ;

  • DropDownList:
myDropDownList.Items[0].Attributes.Add("title", "text").

  • CheckBoxList:

			foreach (ListItem toolTip in <span style="font-weight: bold;">CheckBoxList</span>.Items)
{ DataRow[] dRows =<span style="font-family: Arial, Helvetica, sans-serif;">CheckBoxListID</span>.Select("USER_CNAME = '" + toolTip.Text.ToString() +"'");
if(dRows != null && dRows.Length>0)
{ //this.<span style="font-family: Arial, Helvetica, sans-serif;">CheckBoxListID</span>.Items[i].Attributes.Add("","");
this.<span style="font-family: Arial, Helvetica, sans-serif;">CheckBoxListID</span>.Items[0].Attributes.Add("title", dRows[0]["USER_NAME"].ToString());
toolTip.Attributes.Add("title", dRows[0]["USER_NAME"].ToString());
} }

foreach (ListItem item in ckl_EditRole.Items)
{
item.Attributes["title"] = GetRoleTooltip(item.Value);
}
  • Checkboxlist。Dropdownlist, RedioButtonlist  数据绑定

一、DropDownList:

1、选项值保存到数据库:

   Hashtable ht=new Hashtable();//这里用Hashtable

   ht.Add("字段名"。DropDownListID.SelectedItem.Text.ToString());//保存选项Text

   ht.Add("字段名"。DropDownListID.SelectedItem.Value.ToString());//保存选项Value

2、选项值由数据库绑定到DropDownList:

   首先DropDownListID.ClearSelection();//清除选项

    DropDownListID.Items.FindByText(dr["字段名"].ToString()).Selected = true;//选项Text

    DropDownListID.Items.FindByValue(dr["字段名"].ToString()).Selected = true;//选项Value

二、RadioButtonList:

1、选项值保存到数据库(同DropDownList):

   Hashtable ht=new Hashtable();//这里用Hashtable

   ht.Add("字段名",RadioButtonListID.SelectedItem.Text.ToString());//保存选项Text

   ht.Add("字段名"。RadioButtonListID.SelectedItem.Value.ToString());//保存选项Value

2、选项值由数据库绑定到RadioButtonList

   string SelectItem = dr["字段名"].ToString();//将数据库中的选项值从DataRow中读出赋给变量SelectItem

   for (int i = 0; i < RadioButtonListID.Items.Count; i++)

   {//用for循环推断那项被选种

       if (RadioButtonListID.Items[i].Text == SelectItem)RadioButtonListID.Items[i].Selected = true;

   }

三、CheckBoxList:

1、选项值保存到数据库

   string str1= "";//声明一个变量来接受选项

   for (int i = 0; i < CheckBoxListID.Items.Count; i++)

   {//用for循环将全部选项用","隔开连接起来

        if (CheckBoxListID.Items[i].Selected)

        {

            str1= str1+ CheckBoxListID.Items[i].Value + ",";//选项后加","隔开

        }

   }

   ht.Add("字段名",SelectItem.ToString());

2、选项值由数据库绑定到CheckBoxList

   string SelectItem = dr["字段名"].ToString();

   string[] arrStr = SelectItem.Split(",");//字段是以","隔开

   foreach (string str in arrStr)

   {

       for (int i = 0; i <CheckBoxListID.Items.Count; i++)

       {

          if (this.CheckBoxListID.Items[i].Value == str)

          {

             this.CheckBoxListID.Items[i].Selected = true;

          }

       }

   }

NET:Checkboxlist,Dropdownlist 加入ToolTip说明的更多相关文章

  1. asp.net DropDownList实现ToolTip功能

    在绑定DropDownList控件时,可能出现绑定显示的文本过长以至于超过控件长度的内容看不到,这时候就需要使用ToolTip完成其功能,即鼠标放到相应选项后就可显示其完成内容. 首先,在页面引入jQ ...

  2. Web控件文本框Reset的功能

    在前一篇中<怎样实现Web控件文本框Reset的功能>http://www.cnblogs.com/insus/p/4120889.html Insus.NET只实现了文本框的功能.单个或 ...

  3. form 和 ngModel

    参考 https://docs.angularjs.org/api/ng/type/ngModel.NgModelController https://docs.angularjs.org/api/n ...

  4. Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中

    http://blog.csdn.net/fox123871/article/details/8108030 <script type="text/javascript"&g ...

  5. WebForm复合控件RadioButtonList、CheckBoxList、DropDownList

    1.RadioButtonList     单选集合 -属性:RepeatDirection:Vertical (垂直排布)/Horizontal (横向排布) RepeatLayout:Table ...

  6. MVC扩展HtmlHelper,加入RadioButtonList、CheckBoxList、DropdownList

    代码: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions ...

  7. ListBox,CheckBoxList,DropDownList,RadioButtonList的常见数据绑定

    ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法 四个都是选择控件,用法大同小异,基本都是指定键值对: 直接加选择项: void way1( ...

  8. checkboxlist 下拉框多选功能 ,模拟dropdownlist带复选框效果

    前台代码 01.<html xmlns="http://www.w3.org/1999/xhtml"> 02.<head runat="server&q ...

  9. .NET MVC3中扩展一个HtmlHelper方法CheckBoxList

    MVC中有DropDownList方法,挺好用,可是最常用的需求,一组checkboxlist咋没个类似方法呢?郁闷之余,自己做一个吧,直接上代码 public static MvcHtmlStrin ...

随机推荐

  1. PMP CMM

    CMM和PMP是两个不同的概念域,是用来解决不同问题的.我们所说的CMM,准确的说应该是叫做能力成熟度模型,北京猴子说的软件能力成熟度模型实际上应该称为SW-CMM,是CMM的一个子集.PMP可以看做 ...

  2. 北大青鸟代码---asp.net初学者宝典

    一.上传图片:使用控件:file,button,image; 上传按钮的代码: string fullfilename=this.File1 .PostedFile .FileName ;取得本地文件 ...

  3. Codeforces 538 F. A Heap of Heaps

    \(>Codeforces \space 538 F. A Heap of Heaps<\) 题目大意 :给出 \(n\) 个点,编号为 \(1 - n\) ,每个点有点权,将这些点构建成 ...

  4. [BZOJ1305][CQOI2009]跳舞(网络流)

    1305: [CQOI2009]dance跳舞 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 3944  Solved: 1692[Submit][St ...

  5. BZOJ 1202 [HNOI2005]狡猾的商人(并查集)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1202 [题目大意] 给出一些区间和的数值,问是否存在矛盾 [题解] 用并查集维护前缀和 ...

  6. 【线段树(单点修改,区间求和)】HDU1166 - 敌军布阵

    hdu1166 敌兵布阵,单点修改,区间求和. [ATTENTION]MAXN要开成节点数的4倍,开得不够会提示TLE. #include<iostream> #include<cs ...

  7. Eclipse、svn插件、subclipse的安装

    1.下载subclipse的安装包       URL:http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240   ...

  8. Ucenter添加新应用

    最近手头上有个项目需要用到Ucenter跟Discuz和UcHome整合到一起,使用同步登录.注册,使用同一的用户数据. 以前没用过Ucenter,第一次接触,看过官网的教程感觉不难.于是开始动手,下 ...

  9. winform WebBrowser如何修改使用默认的IE浏览器版本

    在搜了一些相关资料原来WebBrowser使用的是IE的兼容模式进行浏览(IE7模式). 建议:先添加注册表中,然后使用注册表编辑器导出功能,产生reg注册文件:方便日后使用. Winform  We ...

  10. [HTML/CSS]div显示在object、embed之上~

    引言 帮一个朋友弄前端布局,一切都正常,但是嵌入object之后,div总是在object的下面,就上网找了一下解决方案,这里记录一下,好像只对flash有效. 用embed插入一个flash(比如优 ...