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 ...
随机推荐
- python excellent code link
1. Howdoi Howdoi is a code search tool, written in Python. 2. Flask Flask is a microframework for Py ...
- HDU 5828 Rikka with Sequence(线段树 开根号)
Rikka with Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- JZYZOJ1539[haoi2015]T2 树链剖分
http://172.20.6.3/Problem_Show.asp?id=1539 在学校的OJ又写了一次,RE了好多次,原来haoi的时候这道题需要开栈+快读,裸数据结构30分,加上快读50分.o ...
- [Codeforces-div.1 24D] Broken robots
[Codeforces-div.1 24D] Broken robots 试题分析 显然设\(f_{i,j}\)为到\((i,j)\)的期望步数,将转移表达式列出来. 首先自己跟自己的项消掉. 然后规 ...
- 【BFS】The Morning after Halloween
[POJ3523]The Morning after Halloween Time Limit: 8000MS Memory Limit: 65536K Total Submissions: 23 ...
- 搭建vsftpd
安装完软件以后 1.建立用户 adduser ftp passwd 密码 2.修改vsftp.conf文件 anonymous_enable改为NO,阻止匿名上传 Anon_mkdir_write_e ...
- Problem E: 12306
#include <stdio.h> struct student{ int n; int m;}; int main(void) { int T; int k,g,i,j; ],max; ...
- idea创建多个Module
练习不同的算法时,如果不断的创建工程未免过于麻烦,可以使用在一个工程下创建多个Module的方式,编写多种不同的算法,这些模块互相独立,都有一个入口函数(main),并且,对于创建好的Module,如 ...
- java中关于volatile的理解疑问?
作者:xyzZ链接:https://www.zhihu.com/question/49656589/answer/117826278来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请 ...
- java使用HttpClient 发送get、pot请求
package eidolon.messageback.PostUtil; import java.io.BufferedReader; import java.io.IOException; imp ...