• 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. 【java NIO】服务器端读写图片的一次排错经历

    上传文件方面: 一.前端 使用的是jQuery框架来上传图片,参考的是harttle大神博客:http://harttle.com/2016/07/04/jquery-file-upload.html ...

  2. oracle Lower Upper length substr

    字符函数: Lower(char):将字符串装换为小写的格式 Upper(char):将字符串装换为大写的格式 length(char):返回字符串的长度 substr(char,m,n):从m开始截 ...

  3. Linux基础系列-系统密码破解

    无引导介质(光盘.iso)救援模式下root密码破解 第一步: GRUB启动画面读秒时按上下方向键,进入GRUB界面 第二步: 使用上下光标键选择要修改的操作系统启动内核(默认选择的即可),按e键进行 ...

  4. 【构造】【分类讨论】Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

    题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0, ...

  5. 倒置数组 Exercise07_12

    import java.util.Scanner; /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:倒置数组 * */ public class Exercise07_12 ...

  6. uva1632 (区间DP)

    题意:有n个宝藏,在x轴上,每个宝藏在某个时间会消失,问最少吃完所有宝藏的时间是多少,否则输出no solution 分析:区间DP,f[i][j][01]代表i到j区间内的全部吃完,停留在左/右端, ...

  7. CDOJ 1280 772002画马尾 每周一题 div1 矩阵快速幂

    772002画马尾 题目连接: http://acm.uestc.edu.cn/#/problem/show/1280 Description 众所周知772002很喜欢马尾,所以他决定画几幅马尾送给 ...

  8. ApplicationDelegate里的方法

    // 程序第一次加载完毕 - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictio ...

  9. <摘录>ldconfig和ldd用法

    ldconfig和ldd用法 关键字: ldconfig ldd /etc/ld.so.conf LD_LIBRARY_PATH一.ldconfig ldconfig --helpUsage: ldc ...

  10. C# base64编码的字符串与图片互转

    protected string ImgToBase64String(string Imagefilename) { try { Bitmap bmp = new Bitmap(Imagefilena ...