Spread 常用属性
Spread 常用属性
1 取得当前行号、列号。
int row=;
int count=;
或者:
int rowindex = RowIndex;
int columnindex = ColumnIndex;
2 单击一行变颜。
private void spdResult_CellClick(object
ickEventArgs e)
{
//单击Spread列头时,什么也不处理
sender,
if(!Header)
{
if([0].!=0)
{
for(int i=0;i<[0].;i++)
{
[0].Rows[i].BackColor=;
}
int row=;
[0].Rows[row].BackColor=gb((()(192)), (()(255)), (()(255)));
}
}
}
3 将Spread的单元格内容付值给一控件的Text
= [0].Cells[row,count].Text;
4 给Spread的指定单元格付值。
[0].Cells[row,count].Text = ;
5 通过上下光标键改变选中行颜
private void spdResult_LeaveCell(object sender,
ellEventArgs e)
{
//首先检查spread行数是否为0
if([0].==0)
{
return;
}
else
{
for(int i=0;i<[0].;i++)
{
[0].Rows[i].BackColor=;
}
int row=;
[0].Rows[row].BackColor=
gb((()(192)), (()(255)), (()(255)));
}
}
6 下拉列表加载数据(ComBobox)
? 列表追加(适合于数据量少的情况)
oxCellType
oxCellType();
dth = 96;
le = true;
p = 10;
gth = 1;
string[] priceTagList = new string[]{" 0 无"," 1 有"};
= priceTagList;
s[4].CellType = cb4;
? 从数据库追加
cb4 = new
oxCellType
oxCellType();
dth = 150;
le = true;
p = 10;
gth = 8;
cb12 = new
//dsEmployee:数据集Dataset,已经加载好数据的Dataset
string[] employeeList = DataSetToArray(dsEmployee, 8);
= employeeList;
s[12].CellType = cb12;
private string[] DataSetToArray(DataSet ds, int BlankNum)
{
int i = 0;
int NumLength = 0;
string[] returnArray = new string[[0].];
DataRow foundRows = [0].Rows[[0]. -1];
NumLength = foundRows[0].ToString().Length;
foreach(DataRow dr in [0].Rows)
{
returnArray[i] = dr[0].ToString().PadLeft(BlankNum, ' ') +
" " + dr[1].ToString();
i++;
}
return
returnArray;
}
7 Focus移动(跨列)
public frmProdSetDetail()
{
InitializeComponent();
IsMod = flag;
ap im;
im = utMap(cused);
(new
Keystroke(,),NextColumnWrap);
(new
Keystroke(,),NextColumnWrap);
im = utMap(cestorOfFocused);
(new
Keystroke(,),NextColumnWrap);
(new
Keystroke(,),NextColumnWrap);
}
指定单元格获得焦点
iveCell(row,column);
8 事件触发顺序
_Enter _EnterCell _EditModeOn _EditChange
_EditModeOff _LeaveCell
9 用隐藏列保存原始数据
10 设定列类型
private void SpreadSetting()
{
string[] ProductHandleTypeList = new string[]{" ","1
販売/仕入","2 販売","3 仕入"};
oxCellType
oxCellType();
dth = 100;
le = true;
p = 5;
gth = 1;
= ProductHandleTypeList;
cb3 = new
s[5].CellType = cb3;
//设置一般数据型
CellType nmbrcell
CellType();
parator = false;
lPlaces = 0;
gZero
ional;
mValue = 9999;
mValue = 1;
s[13].CellType = nmbrcell;
//设置JAN
CellType nmbrcellJan
CellType();
parator = false;
lPlaces = 0;
gZero
ional;
= new
=
= new
=
mValue = 9999999999999;
mValue = 0;
s[0].CellType = nmbrcellJan;
s[0].HorizontalAlignment
;
//
CellType numberCellType1 = new
CellType();
parator = true;
lPlaces = 0;
gZero
ional;
mValue = 99999999;
mValue = 0;
s[20].CellType = numberCellType1;
//%数的设定
tCellType
tCellType();
prctcell = new
=
=
tSign = "%";
Sh
s[33].CellType = prctcell;
//日期的设定
meCellType datecell = new
meCellType();
mDate = new me(2050, 12, 31, 0, 0, 0, 0);
mDate = new me(2001, 1, 1, 0, 0, 0, 0);
s[27,30].CellType = datecell;
}
11 列、单元格锁定
//锁定
s[0,4].Locked = true;//锁定列范围
s[0].Locked = true;//锁定单列
//解锁
s[0,4].Locked = false;//解锁列范围
s[0].Locked = false;
12 Spread追加行、列
//追加行
int rowindex = ;
(rowindex,1);
//追加列
int columnindex = ;
(columnindex,1);
13 行、列删除
//删除行
(startindex,count);
//追加列
(startindex,count);
14 button事件
private void spdSetList_ButtonClicked(object
NotifyEventArgs e)
{
int rowCount = ;
int columnCount = ;
sender,
if ( == 16)
{
if (ssage("ConfirmDelete", "選択したライン") == )
{
string DeleteTag = [rowCount,
columnCount+1].();
if (DeleteTag == "0" || DeleteTag == "2")
{
[rowCount,
"3";
[rowCount,columnCount+1].BackColor =
clrWater;
[rowCount].Visible = false;
}
else if (DeleteTag == "1")
{
[rowCount].Remove();
}
}
}
}
columnCount+1].Text =
关于Spread打印的一些属性用法__页眉页脚的使用
分类: VB Spread 2007-11-19 14:01 357人阅读 评论(0) 收藏 举报
页眉页脚的使用
使用属性
p_eader = headerstring
p_ooter = headerstring
其中HeaderString是一个字符串,有一些预定义格式,如
/fn"MS Sans Serif"/fz"8.25"/fb0/fi0/fu0/fk0/c中
/fn"MS Sans Serif"/fz"8.25"/fb0/fi0/fu0/fk0/l左
/fn"MS Sans Serif"/fz"18"/fb0/fi0/fu0/fk0/r右
显然有:
/fn"字体"
/fz"字体大小点数"
/c 意为中间部分 类似的 /l /r就不用说了
如果标题有两行以上,则在一行的最后加上 /n ,注意前面要有空格,否则似乎会出错。
主要代码可用调试模式在以下范例窗口中看到
frmPrnHeaderFoolter,这个是我自己改过名了,原来的名字自己去一吧,就是Demo Overview中设置页眉页的部分。
pe = CellT
ypeStaticText
'自动折行
xtWordWrap = True
本文发布于:2024-09-21 15:30:30,感谢您对本站的认可!
本文链接:https://www.17tex.com/fanyi/5557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |