免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
[.NET]CheckBoxList 用法

ASP.NET CheckBoxList組件中經(jīng)常使用到的屬性:

I .TextAlign屬性:取值為:Left、Right。如果TextAlign的值為L(zhǎng)eft則CheckBoxList組件中的檢查框的文字在選框的左邊,同理如果TextAlign的值為Right則檢查框的文字在選框的右邊。

II .Selected屬性:為布爾型,判定組件中的檢查框是否被選中。

III .RepeatColumns屬性:在CheckBoxList組件中有若干檢查框,此屬性主要是設(shè)定這些檢查框到底用多少行來(lái)顯示。

IV .RepeatDirection屬性:此屬性的值可為:Vertical、Horizontal。當(dāng)設(shè)定了RepeatColumns屬性后,設(shè)定此屬性是如何排列組件中的各個(gè)檢查框的。具體如下:

假定CheckBoxList組件有四個(gè)檢查框,并且RepeatColumns屬性值為2。

(1).如果RepeatDirection = Vertical,則在頁(yè)面中檢查框的顯示方式如下:

檢查框01 檢查框03

檢查框02 檢查框04

(2).如果RepeatDirection = Horizontal,則在頁(yè)面中檢查框的顯示方式如下:

檢查框01 檢查框02

檢查框03 檢查框04

V .Count屬性:返回CheckBoxList組件中有多少檢查框。

三. ASP.NET CheckBoxList組件編程中經(jīng)常使用到的方法:

(1).在組件中增加一個(gè)檢查框,語(yǔ)法如下:

  1. CHKList . Items . Add ( new ListItem ( ﹤ text ﹥ , ﹤ value ﹥ ) )

(2).訪問組件中的檢查框,語(yǔ)法如下:

  1. CHKList . Items [ ﹤ index ﹥ ]

(3).刪除組件中的檢查框,語(yǔ)法如下:

  1. CHKList . Items . Remove ( ﹤ index ﹥ )

四. 實(shí)例介紹ASP.NET CheckBoxList組件的使用方法:

(1).如何判定選擇了組件中的哪些檢查框:

在程序中,是通過處理Selected屬性和Count屬性來(lái)完成的,具體如下:

  1. for ( int i = 0 ; i ﹤ ChkList . Items . Count ; i++ ) 
  2. if( ChkList . Items [ i ] . Selected ) 
  3. lblResult . Text += ChkList . Items [ i ] .Text + "  " ; 
  4. }

(2).如何設(shè)定ASP.NET CheckBoxList組件的外觀布局:

CheckBoxList組件有比較多的屬性來(lái)設(shè)定它的外觀,在本文介紹的程序中,主要是通過四個(gè)方面來(lái)設(shè)定組件的外觀布局的:組件中的檢查框中的文本和選框的排列位置、組件中各個(gè)檢查框布局、

組件中各個(gè)檢查框排列方向和組件中各個(gè)檢查框的排列行數(shù),具體的程序代碼如下:

  1. //組件中的檢查框中的文本和選框的排列位置
  2. switch ( cboAlign . SelectedIndex ) 
  3.  case 0 : 
  4. ChkList . TextAlign = TextAlign . Left ; 
  5. break ; 
  6.  case 1 : 
  7. ChkList . TextAlign = TextAlign . Right ; 
  8. break ; 
  9. //組件中各個(gè)檢查框布局
  10. switch ( cboRepeatLayout . SelectedIndex ) 
  11.  case 0 : 
  12. ChkList . RepeatLayout = RepeatLayout . Table ; 
  13. break ; 
  14.  case 1 : 
  15. ChkList . RepeatLayout = RepeatLayout . Flow ; 
  16. break ; 
  17. //組件中各個(gè)檢查框排列方向
  18. switch ( cboRepeatDirection . SelectedIndex) 
  19.  case 0 : 
  20. ChkList . RepeatDirection = RepeatDirection . Vertical ; 
  21. break ; 
  22.  case 1 : 
  23. ChkList . RepeatDirection = RepeatDirection . Horizontal ; 
  24. break ; 
  25. //組件中各個(gè)檢查框的排列行數(shù)
  26. try
  27.  int cols = int . Parse ( txtRepeatCols.Text ) ; 
  28.  ChkList . RepeatColumns = cols ; 
  29. catch ( Exception ) 
  30. }

五. 文中源程序代碼(Check.aspx):

Check.aspx源程序代碼如下:

  1. ﹤% @ Page Language = "C#" %﹥ 
  2. ﹤html ﹥ 
  3. ﹤head ﹥ 
  4. ﹤title ﹥ CheckBoxList組件演示程序 ﹤/title ﹥ 
  5. ﹤script runat = "server" ﹥ 
  6.  protected void Button_Click ( object sender , EventArgs e ) 
  7.  { 
  8. //組件中的檢查框中的文本和選框的排列位置
  9. switch ( cboAlign . SelectedIndex ) 
  10.  case 0 : 
  11. ChkList . TextAlign = TextAlign . Left ; 
  12. break ; 
  13.  case 1 : 
  14. ChkList . TextAlign = TextAlign . Right ; 
  15. break ; 
  16. //組件中各個(gè)檢查框布局
  17. switch ( cboRepeatLayout . SelectedIndex ) 
  18.  case 0 : 
  19. ChkList . RepeatLayout = RepeatLayout . Table ; 
  20. break ; 
  21.  case 1 : 
  22. ChkList . RepeatLayout = RepeatLayout . Flow ; 
  23. break ; 
  24. //組件中各個(gè)檢查框排列方向
  25. switch ( cboRepeatDirection . SelectedIndex) 
  26.  case 0 : 
  27. ChkList . RepeatDirection = RepeatDirection . Vertical ; 
  28. break ; 
  29.  case 1 : 
  30. ChkList . RepeatDirection = RepeatDirection . Horizontal ; 
  31. break ; 
  32. //組件中各個(gè)檢查框的排列行數(shù)
  33. try
  34.  int cols = int . Parse ( txtRepeatCols.Text ) ; 
  35.  ChkList . RepeatColumns = cols ; 
  36. catch ( Exception ) 
  37. lblResult . Text = "" ; 
  38. for ( int i = 0 ; i ﹤ ChkList . Items . Count ; i++ ) 
  39.  if( ChkList . Items [ i ] . Selected ) 
  40.  { 
  41. lblResult . Text += ChkList . Items [ i ] .Text + "  " ; 
  42.  } 
  43.  } 
  44.  ﹤/script ﹥ 
  45.  ﹤/head ﹥ 
  46.  ﹤body ﹥ 
  47.  ﹤form runat = "server" ﹥ 
  48. ﹤h1 align = center ﹥ CheckBoxList組件演示程序 ﹤/h1 ﹥ 
  49. ﹤table ﹥ 
  50.  ﹤tr ﹥ 
  51. ﹤td ﹥ 組件中的文本排列位置: ﹤/td ﹥ 
  52. ﹤td ﹥ 
  53. ﹤asp:DropDownList id = cboAlign runat = "server" ﹥ 
  54.  ﹤asp:ListItem ﹥ 居左 ﹤/asp:ListItem ﹥ 
  55.  ﹤asp:ListItem ﹥ 居右 ﹤/asp:ListItem ﹥ 
  56. ﹤/asp:DropDownList ﹥ 
  57. ﹤/td ﹥ 
  58.  ﹤/tr ﹥ 
  59.  ﹤tr ﹥ 
  60. ﹤td ﹥ 組件中各個(gè)條目布局: ﹤/td ﹥ 
  61. ﹤td ﹥ 
  62. ﹤asp:DropDownList id = cboRepeatLayout runat = "server" ﹥ 
  63.  ﹤asp:ListItem ﹥ 表格型 ﹤/asp:ListItem ﹥ 
  64.  ﹤asp:ListItem ﹥ 緊湊型 ﹤/asp:ListItem ﹥ 
  65. ﹤/asp:DropDownList ﹥ 
  66. ﹤/td ﹥ 
  67.  ﹤/tr ﹥ 
  68.  ﹤tr ﹥ 
  69. ﹤td﹥ 組件中各個(gè)條目排列方向:﹤/td ﹥ 
  70. ﹤td ﹥ 
  71. ﹤asp:DropDownList id = cboRepeatDirection runat = "server" ﹥ 
  72.  ﹤asp:ListItem ﹥ 水平方向 ﹤/asp:ListItem ﹥ 
  73.  ﹤asp:ListItem ﹥ 垂直方向 ﹤/asp:ListItem ﹥ 
  74. ﹤/asp:DropDownList ﹥ 
  75. ﹤/td ﹥ 
  76.  ﹤/tr ﹥ 
  77.  ﹤tr ﹥ 
  78. ﹤td ﹥ 組件中各個(gè)條目排列行數(shù): ﹤/td ﹥ 
  79. ﹤td ﹥ ﹤asp:TextBox id = "txtRepeatCols" runat = "server" /﹥ ﹤/td ﹥ 
  80.  ﹤/tr ﹥ 
  81. ﹤/table ﹥

請(qǐng)選擇你所需要學(xué)習(xí)的計(jì)算機(jī)語(yǔ)言類型:

  1. ﹤asp:CheckBoxList id = "ChkList" RepeatDirection = Horizontal runat = "server" ﹥ 
  2.  ﹤asp:ListItem ﹥ Visual C++ .Net ﹤/asp:ListItem ﹥ 
  3.  ﹤asp:ListItem ﹥ Visual C# ﹤/asp:ListItem ﹥ 
  4.  ﹤asp:ListItem ﹥ VB.NET ﹤/asp:ListItem ﹥ 
  5.  ﹤asp:ListItem ﹥ JScript.NET ﹤/asp:ListItem ﹥ 
  6.  ﹤asp:ListItem ﹥ Visual J# ﹤/asp:ListItem ﹥ 
  7. ﹤/asp:CheckBoxList ﹥ 
  8.  ﹤asp:Button Text = "提交" runat = "server" onclick = "Button_Click" /﹥ 
  9.  ﹤h1 ﹥ ﹤font color = red ﹥ 你選擇的計(jì)算機(jī)語(yǔ)言類型為: ﹤/font ﹥ ﹤/h1 ﹥ 
  10.  ﹤asp:Label id = lblResult runat = "server" /﹥ 
  11.  ﹤/form ﹥ 
  12.  ﹤/body ﹥ 
  13. ﹤/html ﹥ 
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
CheckBoxList - 盼君的日志 - 網(wǎng)易博客
DataList與Repeater
關(guān)于Flutter的RichText組件你了解嗎?
怎樣防止電腦IP地址被盜(圖解)
Flutter學(xué)習(xí)筆記(11)--文本組件、圖標(biāo)及按鈕組件
Flutter學(xué)習(xí)筆記(21)--TextField文本框組件和Card卡片組件
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服