一、TDBGridEH
1、多选 行
options->dgMultiSelect
2、列字体改变颜色,OnDrawColumnCell写下方法。
if Column.FieldName='价格' then begin if ADOQuery1.FieldByName('价格').AsFloat<0 then begin DBGridEh1.Canvas.Font.Color := clRed; DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end; end;
//整个框颜色
DBGridEh1.Canvas.Brush.Color:=clMaroon;
DBGridEh1.Canvas.Font.Color:=clWhite;
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
3、字段显示分层
如实现 这种效果
1、选择TDBGridEH,设置属性:UseMultiTitle:True.
2、右击TDBGridEH,选择Columns Editor,选择上分层的字段,如:caption:重量|生铁
二、TDBNumberEditEh:保能输入数字
1、Imemode属性:
imClose 表示输入法处于关闭状态;
ImOpen 表示输入法处于打开状态;
ImChinese 表示处于中文输入法状态;
ImDontCare 表示若输入法处于关闭状态则打开最近一次使用过的输入法;
ImSAlpha 表示输入处于半角状态;
ImAlpha 表示输入处于全角状态。
2、出现上下箭头
DBNumberEditEh1.EditButton.Visible:=true;
DBNumberEditEh1.EditButton.Style:=ebsDropDownEh;
问题:滑动鼠标会自动增加数字,因不需此功能,又无法去掉这个功能,后改用RzEdit里的控件。
三、TDBComboBoxEh
二、公用方法
function AddComboBoxEhList(TableName, KeyField, DisplayField: String;
CbB: TDbComboBoxEh; Condition: string = '';
bClear: Boolean = True): Boolean;
var DQ: TADOQuery;
begin
DQ := TADOQuery.Create(nil);
with DQ do
try
Result := False;
Connection := DMW_Public.DC_Pub;
Close;
SQL.Clear;
SQL.Add('select '+DisplayField);
if Trim(KeyField) <> '' then
SQL.Add(','+KeyField);
SQL.Add(' from '+ TableName);
if Condition <> '' then SQL.Add(Condition);
Open;
if bClear then
begin
CbB.KeyItems.Clear;
CbB.Items.Clear;
end;
while not Eof do
begin
if Trim(KeyField) <> '' then
CbB.KeyItems.Add(FieldByName(KeyField).AsString);
CbB.Items.Add(FieldByName(DisplayField).AsString);
Next;
end;
Result := True;
finally
Close;
Free;
end;
end;
直接 引用 : AddComboBoxEhList('pub_departments','id','name',cbb_department,' Order by id ');
添加/修改:cbb_department.KeyItems[cbb_department.ItemIndex]
修改加载:
1)已知item:cbb_department.Text:=FieldByName('syb').AsString;
2)只知keyItem: cbb_range.ItemIndex:= cbb_range.KeyItems.IndexOf(FieldByName('range').AsString);
根据条件加载:
AddComboBoxEhList('pub_branchs','id','name',cbb_FC,' Where pub_department_id='''+cbb_department.KeyItems[cbb_department.ItemIndex]+''' Order by id ');
清除内容:cbb_FC.Clear;
每次重新加载要清除KeyItems,Items