spread应用

本文介绍如何使用 FarPoint Spread 控件为 Excel 类似的工作表中的单元格设置下拉列表功能。具体包括从数组和数据库两种方式加载数据,并展示了如何配置 ComboBoxCellType 的属性。

下拉列表加载数据(ComBobox)

列表追加

FarPoint.Win.Spread.CellType.ComboBoxCellType cb4 = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
   cb4.ListWidth 
= 96;
   cb4.Editable 
= true;
   cb4.MaxDrop 
= 10;
   cb4.MaxLength 
= 1;
   
string[] priceTagList = new string[]{" 0  無し"," 1 有り"};
   cb4.Items 
= priceTagList;
   
this.spdSetList.ActiveSheet.Columns[4].CellType = cb4;

 

数据库追加

 

FarPoint.Win.Spread.CellType.ComboBoxCellType cb12 = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
   cb12.ListWidth 
= 150;
   cb12.Editable 
= true;
   cb12.MaxDrop 
= 10;
   cb12.MaxLength 
= 8;
   
string[] employeeList = DataSetToArray(dsEmployee, 8);
   cb12.Items 
= employeeList;
   
this.spdSetList.ActiveSheet.Columns[12].CellType = cb12;

private string[] DataSetToArray(DataSet ds, int BlankNum)
  
{
   
int i = 0;
   
int NumLength = 0;
   
string[] returnArray = new string[ds.Tables[0].Rows.Count];

   DataRow foundRows 
= ds.Tables[0].Rows[ds.Tables[0].Rows.Count -1];
   NumLength 
= foundRows[0].ToString().Length;

   
foreach(DataRow dr in ds.Tables[0].Rows)
   
{
    returnArray[i] 
= dr[0].ToString().PadLeft(BlankNum, ' '+ " " + dr[1].ToString();
    i
++;
   }

   
return returnArray;
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值