advstringgrid 使用Word格式.docx
《advstringgrid 使用Word格式.docx》由会员分享,可在线阅读,更多相关《advstringgrid 使用Word格式.docx(16页珍藏版)》请在冰豆网上搜索。
进入单元格时自动变成编辑状态
Navigation—AdvanceOnEnter=true:
回车时自动移到下一个CELL
Navigation—AdvancelInsert:
控制当光标在最后一个CELL时是否可以按回车插入新行
Navigation—AllowDeleteRow:
控制是否按DELETE键删除当前行
Navigation—AppendOnArrowDown:
控制按下箭头是否可以新增一行(未找到这个属性)
MouseActions—RowSelect/ColSelect=true:
选择整行/选择整列
Navigation—AutoComboDropSize=true组合框下拉框展开宽度自动设置
MouseActions—DirectComboDrop=True组合框进入时自动展开
(点击鼠标时直接进入编辑,或允许、不允许改变行或列宽等特性,都可以在MouseActions中设置。
AutoNumAlign:
=True则数字类型数据在CELL里会自动右对齐
AutoNumberCol(n);
自动在第n列按顺序显示数字,即1,2,3……
AutoSize:
=true:
自动设置列宽,不推荐使用,自动调整后,真的很难看。
EnableWheel:
一次滚动多行,EnableWheel:
=False时,一次滚动一行。
SearchFooter—Visible:
=TRUE时,会在ADVStringGrid的底部显示出搜索框(未找到属性)
FloatingFooter—Visible:
为TRUE时,即在ADVStringGrid底部显示求和列,要想让求和列显示小数,还需要将FloatFormat属性设置为:
%g(未找到属性)
(自动换行到新追回行:
必须在onCellValidate过程中执行strGrid.AddRow;
可以同时加一些赋值语句。
(当合并行后,如果想使文字垂直居中,可以先设置ADVStringGrid的MultilineCells设置为True,然后在文字前面加#13换行来实行)
(改变固定列的显示样式:
ControlLook——FixedGradientFrom(起始色)——FixedGradientFrom(结束色)
+++
用过程设置相关属性
---
1,设定单元表各列是否可以编辑:
首先在设置属性:
Options—goEditing=true;
然后,在CanEditCell事件中设定。
procedureTForm50.stgPartListCanEditCell(Sender:
TObject;
ARow,ACol:
Integer;
varCanEdit:
Boolean);
Var
I:
integer;
begin
if(stgPartList.cells[cC1Data_Flag,ARow]='
'
)or(stgPartList.cells[cC1Data_Flag,ARow]='
C'
)thenbegin
canEdit:
=false;
exit;
endelsebegin
forI:
=0tocColQty1dobegin
ifACol=Ithenbegin
ifstgPartList.cells[cC1Data_Flag,aRow]='
thenCanEdit:
=false
elsebegin
ifcColProp1[I,1]='
Y'
=true;
//cColProp1:
列属性数组,下同
N'
=False;
end;
2,设定单元表各列对齐方式:
在GetAlignment事件中设定。
procedureTForm1.strGrid1GetAlignment(Sender:
varAAlignment:
TAlignment);
//直接定义
{ifARow=0thenAAlignment:
=tacenter
caseAColof
0:
AAlignment:
=taRightJustify;
1:
=taCenter;
//2:
3:
4:
6:
8:
9:
elseAAlignment:
=taLeftJustify;
}
//用属性数组定义
ifARow=0thenAAlignment:
=taCenter
=0toxpColQty1-1dobegin
//casestrToInt(xaColProp1[I,4])
ifxaColProp1[I,4]='
thenAAlignment:
L'
R'
{//以下代码不明,此过程没有HAlign,VAlign
HAlign:
=taCenter;
VAlign:
=vtaCenter;
}
3,改变单元格的背景色,可在OnGetCellColor事件中写代码实行(前提需将FLAT设置为TRUE)/设定Grid颜色:
在GetCellColor事件中设定:
procedureTForm50.stgPartListGetCellColor(Sender:
ARow,
ACol:
AState:
TGridDrawState;
ABrush:
TBrush;
AFont:
TFont);
{ifstgPList.Cells[cNCols1[3]-2,ARow]='
1'
then
abrush.Color:
=clScrollBar
if(ARow=0)or(ACol=0)then
=clBtnFace
ifACol=cNCols1[2]-2then
=clwindow
else
=clinfoBK;
ifARow=0then
ifACol=Ithenabrush.Color:
=StringToColor(cColProp1[I,5]);
{ifARow=0thenbegin//如果不加这一句,则是以下对应的整列,我这里是只改变固列,所以要把ARow设为0
CaseAColof
ABrush.Color:
=RGB(227,249,248);
2:
=RGB(250,232,193);
12:
14:
24:
48:
51:
End;
END;
4,设置Grid中列特殊类型,某一列的数据格式,预定义的格式有:
enumTEditorType{edNormal,edSpinEdit,edComboEdit,edComboList,edEditBtn,edCheckBox,edDateEdit,edDateEditUpDown,edTimeEdit,edButton,edDataCheckBox,edNumeric,edPositiveNumeric,edFloat,edCapital,edMixedCase,edPassword,edUnitEditBtn,edLowerCase,edUpperCase,edFloatSpinEdit,edTimeSpinEdit,edDateSpinEdit,edNumericEditBtn,edFloatEditBtn,edCustom,edRichEdit,edNone,edUniEdit,edUniComboEdit,edUniComboList};
通过OnGetEditorType()事件进行设置,例如:
procedureTForm1.strGrid1GetEditorType(Sender:
ACol,ARow:
varAEditor:
TEditorType);
switch(aCol)
case1:
aEditor=edComboList;
break;
//设置第一列为ComboBox类型输入
case2:
aEditor=edEditBtn;
//设置第二列为EditBtn类型输入,弹出一个选择框
case3:
aEditor=edSpinEdit;
//设置第三列为SpinEdit类型输入
case4:
aEditor=edDa