DBGrid的自定义字段的问题。(50分)

  • 主题发起人 xiatianyun
  • 开始时间
X

xiatianyun

Unregistered / Unconfirmed
GUEST, unregistred user!
在DBGrid中增加一个自定义字段(相当于计算列),在OnDrawColumnCell中不能正确对该字段进行操作,请大家告诉我一声。
所增字段名FieldName:ChenBen
if DBGrid1.SelectedField.FieldName ='ChenBen' then //此处出错
begin
...
end;
 
SelectedField 有可能为 nil
if ((DBGrid1.SelectedField<>nil) and (uppercase(DBGrid1.SelectedField.FieldName)='ChENBEN')) then


Set SelectedField to move focus to a particular field in the grid. Read SelectedField to obtain access to the field component for the currently selected cell. If there is not currently selected cell, SelectedField is nil. For example, when an entire row is selected, SelectedField is nil.
 
SelectedField 有可能为 nil
if (DBGrid1.SelectedField<>nil) then
if (uppercase(DBGrid1.SelectedField.FieldName)='ChENBEN') then
begin
....
end;


Set SelectedField to move focus to a particular field in the grid. Read SelectedField to obtain access to the field component for the currently selected cell. If there is not currently selected cell, SelectedField is nil. For example, when an entire row is selected, SelectedField is nil.
 
顶部