读书人

Delphi7中有没可以直接在cell中输入数

发布时间: 2012-02-19 19:43:38 作者: rapoo

Delphi7中有没可以直接在cell中输入数据的gird控件
Delphi7中有没可以直接在cell中输入数据的gird控件?在那个页签下啊?

[解决办法]
stringgrid 比较好控制~
F1Book 没用过..看上去不错..

我一般都用TMS AdvStringGrid
[解决办法]
datagrid 足够了,TColumn.ReadOnly可以控制其是否只读。

{表字段字典}
PDicField=^TDicField;
TDicField=record
code : string; {表代码}
id : integer; {序号}
name : string; {字段名称}
cName : string; {中文名称}
sName : string; {显示名称}
constant : string; {字段常量}
userType : char; {字段用户类型}
isShow : boolean; {是否显示}
showBlock: string; {显示控制块}
format : string; {显示格式}
width : integer; {宽度}
uiType : char; {界面表现形式}
ctrl : smallint; {控制字}
query : boolean; {是否可作为查询条件}
end;
{字段列表--------------------------------}
TDicFieldList=record
nFields: integer;
fields : array of TDicField;
end;

//动态生成DBGrid表头,生成的表头来自字典。
//动态生成时,可控制各列的表现形式,如下拉框、按钮,并且可控制读/写属性
procedure G_BuildDBGridHead(const DBGrid: TDBGrid; DicFields: TDicFieldList);
var
i: Integer;
ValueLst: TStrings;
newColumn: TColumn;
begin
DBGrid.Columns.Clear;
for i:=0 to DicFields.nFields-1 do
begin
if not DicFields.Fields[i].isShow then Continue;
newColumn := DBGrid.Columns.Add;
newColumn.Title.Alignment := taCenter;
newColumn.Title.Caption := DicFields.Fields[i].sName;
newColumn.FieldName := DicFields.Fields[i].name;
newColumn.Width := DicFields.Fields[i].width;

case DicFields.Fields[i].uiType of
'C':begin
ValueLst := TStringList.Create;
G_SeperateString(DicFields.Fields[i].constant,ValueLst);
newColumn.PickList.AddStrings(ValueLst);
newColumn.DropDownRows := 20;
ValueLst.Free;
newColumn.Color := clCream;
newColumn.ButtonStyle := TColumnButtonStyle(cbsAuto);
end;
'B':NewColumn.ButtonStyle := TColumnButtonStyle(cbsEllipsis);
end;
newColumn.ReadOnly := DicFields.fields[i].ctrl<3;
if newColumn.ReadOnly then newColumn.Color := clReadOnly;
end;
if DBGrid.ReadOnly then DBGrid.Options := DBGrid.Options+[dgRowSelect];
end;

读书人网 >.NET

热点推荐