標籤:tooltip c#
ToolTip 類 (System.Windows.Controls)?
表示建立彈出項的控制項,該彈出項可顯示介面中元素的相關資訊。命名空間: System.Windows.Controls 程式集: PresentationFramework
ToolTip 類 (System.Windows.Forms)?
表示一個長方形的小快顯視窗,該視窗在使用者將指標懸停在一個控制項上時顯示有關該控制項用途的簡短說明。
以上摘自 MSDN官網。
其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 ;
myDropDownList.Items[0].Attributes.Add("title", "text").
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;
}
}
}