delphi 中cxverticalgrid怎么判断用户在int型的字段里输入string型的信息。如果是string型就提示:
‘请输入数字’,并且把该行清空。代码:procedureTForm1.FormCreate(Sender:TObject);beginwithadoquery1dobeg...
‘请输入数字’,并且把该行清空。代码:procedure TForm1.FormCreate(Sender: TObject);
begin
with adoquery1 do
begin
Close;
sql.Clear;
SQL.Text:=('select * from XX');
Open;
cxVerticalGrid1EditorRow1.Properties.Value:=fieldbyname('stu').AsString;
cxVerticalGrid1EditorRow2.Properties.Value:=fieldbyname('year').AsString;
cxVerticalGrid1EditorRow3.Properties.Value:=fieldbyname('sex').AsString;
cxVerticalGrid1EditorRow4.Properties.Value:=fieldbyname('gl').AsString;
Exit;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1 do
begin
try
Close;
SQL.Clear;
SQL.Text:=('select * from XX');
Open;
Edit;
FieldByName('stu').AsString:=cxVerticalGrid1EditorRow1.Properties.Value;
FieldByName('year').AsString:=cxVerticalGrid1EditorRow2.Properties.Value;
FieldByName('sex').AsString:=cxVerticalGrid1EditorRow3.Properties.Value;
FieldByName('gl').AsString:=cxVerticalGrid1EditorRow4.Properties.Value;
Post;
ShowMessage('OK');
except
ShowMessage('请输入数字');
cxVerticalGrid1EditorRow2.Properties.Value:='';
cxVerticalGrid1EditorRow4.Properties.Value:='';
end;
end;
其中,year和gl字段是int型的。问题是:无论我在row2或者row4输入string都会2行一起清空。请问下 该怎么改。 展开
begin
with adoquery1 do
begin
Close;
sql.Clear;
SQL.Text:=('select * from XX');
Open;
cxVerticalGrid1EditorRow1.Properties.Value:=fieldbyname('stu').AsString;
cxVerticalGrid1EditorRow2.Properties.Value:=fieldbyname('year').AsString;
cxVerticalGrid1EditorRow3.Properties.Value:=fieldbyname('sex').AsString;
cxVerticalGrid1EditorRow4.Properties.Value:=fieldbyname('gl').AsString;
Exit;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1 do
begin
try
Close;
SQL.Clear;
SQL.Text:=('select * from XX');
Open;
Edit;
FieldByName('stu').AsString:=cxVerticalGrid1EditorRow1.Properties.Value;
FieldByName('year').AsString:=cxVerticalGrid1EditorRow2.Properties.Value;
FieldByName('sex').AsString:=cxVerticalGrid1EditorRow3.Properties.Value;
FieldByName('gl').AsString:=cxVerticalGrid1EditorRow4.Properties.Value;
Post;
ShowMessage('OK');
except
ShowMessage('请输入数字');
cxVerticalGrid1EditorRow2.Properties.Value:='';
cxVerticalGrid1EditorRow4.Properties.Value:='';
end;
end;
其中,year和gl字段是int型的。问题是:无论我在row2或者row4输入string都会2行一起清空。请问下 该怎么改。 展开
1个回答
展开全部
你没有判断上边是ROW2还是ROW4里边是STRING,下边直接就把ROW2和ROW4都清了...当然是什么情况下都会两行一起清.....给showmessage('请输入数字')下边加判断.
追问
怎么加啊 我菜鸟哦 ,提示下 谢谢
追答
你 create 的时候执行的cxVerticalGrid1EditorRow2.Properties.Value:=fieldbyname('year').AsString;这让cxVerticalGrid1EditorRow2.Properties.Value就是string 型的...你只能判断他里边有没有a-Z了!!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询