当前位置:首页 > 网络编程 > WEB编程 > ASP.net > ASP.NET中WebForm组件CheckBoxList编程(3)

ASP.NET中WebForm组件CheckBoxList编程(3)

点击次数:23 次 发布日期:2008-11-27 00:06:06 作者:源代码网
源代码网推荐      四. 实例介绍CheckBoxList组件的使用方法:
源代码网推荐  
源代码网推荐    (1).如何判定选择了组件中的哪些检查框:
源代码网推荐  
源代码网推荐    在程序中,是通过处理Selected属性和Count属性来完成的,具体如下:
源代码网推荐  
源代码网推荐  for ( int i = 0 ; i < ChkList . Items . Count ; i++ )
源代码网推荐  {
源代码网推荐  if( ChkList . Items [ i ] . Selected )
源代码网推荐  {
源代码网推荐  lblResult . Text += ChkList . Items [ i ] .Text + " <br > " ;
源代码网推荐  }
源代码网推荐  }
源代码网推荐  
源代码网推荐    (2).如何设定CheckBoxList组件的外观布局:
源代码网推荐  
源代码网推荐    CheckBoxList组件有比较多的属性来设定它的外观,在本文介绍的程序中,主要是通过四个方面来设定组件的外观布局的:组件中的检查框中的文本和选框的排列位置、组件中各个检查框布局、组件中各个检查框排列方向和组件中各个检查框的排列行数,具体的程序代码如下:
源代码网推荐  
源代码网推荐  //组件中的检查框中的文本和选框的排列位置
源代码网推荐  switch ( cboAlign . SelectedIndex )
源代码网推荐  {
源代码网推荐   case 0 :
源代码网推荐    ChkList . TextAlign = TextAlign . Left ;
源代码网推荐    break ;
源代码网推荐   case 1 :
源代码网推荐    ChkList . TextAlign = TextAlign . Right ;
源代码网推荐    break ;
源代码网推荐  }
源代码网推荐  //组件中各个检查框布局
源代码网推荐  switch ( cboRepeatLayout . SelectedIndex )
源代码网推荐  {
源代码网推荐   case 0 :
源代码网推荐    ChkList . RepeatLayout = RepeatLayout . Table ;
源代码网推荐    break ;
源代码网推荐   case 1 :
源代码网推荐    ChkList . RepeatLayout = RepeatLayout . Flow ;
源代码网推荐    break ;
源代码网推荐  }
源代码网推荐  
源代码网推荐  //组件中各个检查框排列方向
源代码网推荐  switch ( cboRepeatDirection . SelectedIndex)
源代码网推荐  {
源代码网推荐   case 0 :
源代码网推荐    ChkList . RepeatDirection = RepeatDirection . Vertical ;
源代码网推荐    break ;
源代码网推荐   case 1 :
源代码网推荐    ChkList . RepeatDirection = RepeatDirection . Horizontal ;
源代码网推荐    break ;
源代码网推荐  }
源代码网推荐  
源代码网推荐  //组件中各个检查框的排列行数
源代码网推荐  try
源代码网推荐  {
源代码网推荐   int cols = int . Parse ( txtRepeatCols.Text ) ;
源代码网推荐   ChkList . RepeatColumns = cols ;
源代码网推荐  }
源代码网推荐  catch ( Exception )
源代码网推荐  {
源代码网推荐  }
源代码网推荐  
源代码网推荐  


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华