findcomponent(str)只能在str控件存在的情况下有效,如果此控件不存在,则出错
怎么样去判断str是否存在?
望大家不吝赐教

解决方案 »

  1.   

    try
    findcomponent(str);
    except
    //如果STR不存在,那么怎么办
    end;
      

  2.   

    try
      findcomponent(str)
    except
      showmessage('此控件不存在');
    end;
      

  3.   

    对于一个TListBox如 ListBox1 我可以用FindComponent('ListBox1')来判断它是否存在,
      

  4.   

    怎么捕获不到由FindComponent引发的错误啊?
      

  5.   

    if FindComponent('ListBox1') = nil then
       showmessage('Error')
    else
       showmessage('OK');