【www.gdgbn.com--邮件处理】
四. 实例介绍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 ;