try
szSelected:= dbgrdShowData.SelectedField.Text; except
MessageBox(Handle,'还没有选择要查看的信息,请选择','错误',MB_ICONERROR);
end;dbgrdShowData是一个DBGrid,我希望得到他选中的Cell的信息,如果这个时候dbgrdShowData里面没有数据或者是用户没有进行选择,就弹出一个错误提示框,为什么根本不行?不是出现异常会转入except进行处理的么?怎么还是弹出系统的那个错误框的啊,---------------------------
Debugger Exception Notification
---------------------------
Project ExamInfoManager.exe raised exception class EAccessViolation with message 'Access violation at address 0047F73D in module 'ExamInfoManager.exe'. Read of address 000000D2'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
szSelected:= dbgrdShowData.SelectedField.Text; except
MessageBox(Handle,'还没有选择要查看的信息,请选择','错误',MB_ICONERROR);
end;dbgrdShowData是一个DBGrid,我希望得到他选中的Cell的信息,如果这个时候dbgrdShowData里面没有数据或者是用户没有进行选择,就弹出一个错误提示框,为什么根本不行?不是出现异常会转入except进行处理的么?怎么还是弹出系统的那个错误框的啊,---------------------------
Debugger Exception Notification
---------------------------
Project ExamInfoManager.exe raised exception class EAccessViolation with message 'Access violation at address 0047F73D in module 'ExamInfoManager.exe'. Read of address 000000D2'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
不过有些异常,dELPHI捕获不到而已
有我们在,DELPHI就不会倒
而且从08起DELPHI已经慢慢恢复元气
楼主代码写错了
要这样写
try
...........
except
exit;
ShowMessage('error');
end;很多书上对DELPHI的异常处理都写错了
少了exit楼主给点会吧
我没分用了
谢谢
不过楼主我觉得你可以用if DbGrid.DataSource.DataSet.RecordCount = 0 then
来判断DBGrid里面有没有数据。
szSelected:= dbgrdShowData.SelectedField.Text;