• 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;

          }

       }

   }

最新文章

  1. SQL参数化查询自动生成SqlParameter列表
  2. PHP 函数基础
  3. D1
  4. 使用ajax异步提交表单数据(史上最完整的版本)
  5. PowerShell脚本:随机密码生成器
  6. VS2010+Selenium测试脚本设计
  7. m3u8文件简介
  8. struts2结构图
  9. Asp.net 身份验证
  10. solaris知识库
  11. Jetty学习(一)
  12. Delphi WebBrowser控件的使用(大全 good)
  13. 解析一下rtmp协议比较难懂的地方
  14. 【Vue】Vue初探
  15. POJ1037 A decorative fence
  16. 一个小白用 PhotoView 引起的学习记录
  17. CSS Modules入门教程
  18. 毕业论文Word格式技巧
  19. C++的默认构造函数
  20. 通过url传递参数如果汉字乱码采用的方法

热门文章

  1. JavaWeb中常见的乱码处理(亲测)
  2. asp总结
  3. BZOJ 2697 特技飞行(贪心)
  4. [xsy2880]取石子游戏
  5. windows下wnmp配置
  6. CentOS 6.9下iptables通过raw表实现日志输出和调试
  7. AS3.0 Vector的运用
  8. java8 遍历数组的几种方式
  9. iOS:多线程同步加锁的简单介绍
  10. phpstorm不安装apache就可以本地测试PHP