奇怪的问题(20分)

  • 主题发起人 主题发起人 handsome1234
  • 开始时间 开始时间
H

handsome1234

Unregistered / Unconfirmed
GUEST, unregistred user!
if KEY = #13 then
begin
if not (ACTIVECONTROL as DBGrid1) then
//[Error] Unit1.pas(137): Operator not applicable to this operand type
begin
Key := #0;
PERFORM(WM_NEXTDLGCTL, 0, 0);
end else
begin
if (ACTIVECONTROL as DBGrid1) then
//[Error] Unit1.pas(143): Operator not applicable to this operand type
begin
with DBGrid1(ACTIVECONTROL) do
begin
if SELECTEDINDEX < (FIELDCOUNT - 1) then SELECTEDINDEX := SELECTEDINDEX + 1 else
Sendmessage(Handle, wm_keydown, vk_Tab, 0);
end;
end;
end;
end;

 
procedure SetFocusToNext(Form: TObject; Key: Word);
begin
with Form as TForm do
case Key of
VK_Return://&amp;Iuml;ì&amp;Oacute;&amp;brvbar;&amp;raquo;&amp;Oslash;&amp;sup3;&amp;micro;&amp;frac14;ü&amp;iexcl;&amp;pound;
begin
if (not (ActiveControl is TDBGrid)) and (not (ActiveControl is TMemo))and(not(activecontrol is trichedit)) then
begin
PerForm(WM_NEXTDLGCTL, 0, 0);
end
else if (ActiveControl is TDBGrid) then
with TDBGrid(ActiveControl) do
if selectedIndex < (FieldCount - 1) then
selectedIndex := selectedIndex + 1
else
selectedIndex := 0;
end;
VK_ESCape://&amp;Iuml;ì&amp;Oacute;&amp;brvbar;ESC&amp;frac14;ü&amp;iexcl;&amp;pound;
begin
if application.MessageBox('&amp;Ecirc;&amp;Ccedil;·&amp;ntilde;&amp;sup1;&amp;Oslash;±&amp;Otilde;&amp;micro;±&amp;Ccedil;°&amp;acute;°&amp;iquest;&amp;Uacute;&amp;pound;&amp;iquest;', 'RelTest', MB_YesNo + MB_ICONQUESTION) = id_yes then
Close;
end;
44 {VK_Print}://&amp;Iuml;ì&amp;Oacute;&amp;brvbar;&amp;acute;ò&amp;Oacute;&amp;iexcl;&amp;frac14;ü&amp;iexcl;&amp;pound;
if application.MessageBox('&amp;acute;ò&amp;Oacute;&amp;iexcl;&amp;micro;±&amp;Ccedil;°&amp;acute;°&amp;iquest;&amp;Uacute;&amp;Acirc;&amp;eth;&amp;pound;&amp;iquest;', 'RelTest', MB_YesNo + MB_ICONQUESTION) = id_yes then
begin
Print;
end;
end;
end;
 
用is 而不是用as,同意楼上的
 
我的问题是:用as or is都是出现:
[Error] Unit1.pas(137): Operator not applicable to this operand type
这个error,所以看看大家怎么解决啊
 
as 后应该是类名,而不是对象名:
ACTIVECONTROL as Tdbgrid
is同理
 
你的语句太乱了:

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin

if KEY <> #13 then exit;
if not (ACTIVECONTROL = DBGrid1) then
begin
Key := #0;
PERFORM(WM_NEXTDLGCTL, 0, 0);
end
else
with TDBGrid(ACTIVECONTROL) do
if SELECTEDINDEX < (FIELDCOUNT - 1) then
SELECTEDINDEX := SELECTEDINDEX + 1
else
Sendmessage(Handle, wm_keydown, vk_Tab, 0);

end;
 
ugvanxk的 TDBGrid与你的 DBGrid1相吗?
ugvanxkrr的是正确的
 
对是应该是is 并且is后面应该跟类名
 
后退
顶部