NET:Checkboxlist,Dropdownlist 加入ToolTip说明
- 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说明的更多相关文章
- asp.net DropDownList实现ToolTip功能
在绑定DropDownList控件时,可能出现绑定显示的文本过长以至于超过控件长度的内容看不到,这时候就需要使用ToolTip完成其功能,即鼠标放到相应选项后就可显示其完成内容. 首先,在页面引入jQ ...
- Web控件文本框Reset的功能
在前一篇中<怎样实现Web控件文本框Reset的功能>http://www.cnblogs.com/insus/p/4120889.html Insus.NET只实现了文本框的功能.单个或 ...
- form 和 ngModel
参考 https://docs.angularjs.org/api/ng/type/ngModel.NgModelController https://docs.angularjs.org/api/n ...
- Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中
http://blog.csdn.net/fox123871/article/details/8108030 <script type="text/javascript"&g ...
- WebForm复合控件RadioButtonList、CheckBoxList、DropDownList
1.RadioButtonList 单选集合 -属性:RepeatDirection:Vertical (垂直排布)/Horizontal (横向排布) RepeatLayout:Table ...
- MVC扩展HtmlHelper,加入RadioButtonList、CheckBoxList、DropdownList
代码: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions ...
- ListBox,CheckBoxList,DropDownList,RadioButtonList的常见数据绑定
ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法 四个都是选择控件,用法大同小异,基本都是指定键值对: 直接加选择项: void way1( ...
- checkboxlist 下拉框多选功能 ,模拟dropdownlist带复选框效果
前台代码 01.<html xmlns="http://www.w3.org/1999/xhtml"> 02.<head runat="server&q ...
- .NET MVC3中扩展一个HtmlHelper方法CheckBoxList
MVC中有DropDownList方法,挺好用,可是最常用的需求,一组checkboxlist咋没个类似方法呢?郁闷之余,自己做一个吧,直接上代码 public static MvcHtmlStrin ...
随机推荐
- [BZOJ3456]城市规划(生成函数+多项式求逆+多项式求ln)
城市规划 时间限制:40s 空间限制:256MB 题目描述 刚刚解决完电力网络的问题, 阿狸又被领导的任务给难住了. 刚才说过, 阿狸的国家有n个城市, 现在国家需要在某些城市对之间建立一 ...
- AGC 026 C - String Coloring
题面在这里! 比较简单的折半搜索,推一下hash函数,要求正反最后相等就行了. #include<bits/stdc++.h> #define ll unsigned long long ...
- 【斜率优化】bzoj3675-[Apio2014]序列分割&&Uoj104
题目大意 将一个长度为N的非负整数序列分割成k+l个非空的子序列,每次选择一位置分割后,将会得到一定的分数,这个分数为两个新序列中元素和的乘积.求最大的分数. [UOJ104]并输出任意一种方案 思路 ...
- 【优先队列+贪心】POJ2431-Expedition
解题方法详见<挑战程序设计竞赛(第二版)>P74-75.注意首先要对加油站以位置为关键字快排,不要遗忘把终点视作一个加油量为0的加油站,否则最终只能到达终点前的加油站. /*优先队列*/ ...
- bzoj 3790: 神奇项链
3790: 神奇项链 Description 母亲节就要到了,小 H 准备送给她一个特殊的项链.这个项链可以看作一个用小写字 母组成的字符串,每个小写字母表示一种颜色.为了制作这个项链,小 H 购买了 ...
- html基础知识介绍
1 前端概要 前端三大利器 1.html 赤裸裸的人 2.css 穿上华丽的衣服 3.js 让人生动起来 2 HTML本质及在web程序中的作用 2.1 介绍 HTML 1.一套规则,浏览 ...
- django框架下celery+rabbitmq+flower完成异步任务
[转载请注明出处:] http://www.cnblogs.com/yukityan/p/8035787.html 环境: ubuntu16.04 64位 安装: sudo apt-get insta ...
- 关于abstract class 和 interface
1.abstract class 在 Java 语言中表示的是一种继承关系,一个类只能使用一次继承关系.但是,一个类却可以实现多个interface. 2.在abstract class 中可以有自己 ...
- iOS .a静态库的制作及使用
一.制作.a静态库 1.创建静态库工程,工程命名为BaseSDK,生成的.a文件名变成libBaseSDK.
- 微信小程序官方文档
开发手册: https://developers.weixin.qq.com/miniprogram/dev/api/network-file.html 管理后台: https://mp.weixin ...