if (nationality.Items.IndexOf(nationality.Text) < 0) and (nationality.text<>'') then 
 ......
 ......

解决方案 »

  1.   

    nationality.text里我填的是'英国'呀,并不是'',所以上面的程序也是不行的,更正一下,显示格式是:高中       中国
             本科
             硕士
             博士
                        英国
    是不是表结构的问题呢,它把“英国”添加入新的一行了,其实我的目的是想让“英国”和“本科”在一行里的。    
      

  2.   

    初始的时候把COMBOBOX的STRING属性打开然后用,”<-“键把空行删除即可。
      

  3.   

    你的程序很乱,table和combobox都分不清楚!你看清楚在重新讲一遍!
      

  4.   

    你的程序中combofield如果是table的话,照你的意思应该是edit而不是insert!
      

  5.   

    combofield是我在oracle里建立的一张表的名字,用table控件建立连接的,nationality是表中的一个字段名。请指教。
      

  6.   

    当然在界面里,nationality也是一个combobox的name。我的意思就是通过这个combobox添加新的内容“英国”,(把内容永久加入表combofield中nationality字段中去),可是总是有空白行的。表中显示: edulevel   nationality
                      高中         中国
                      本科
                      硕士
                      博士
                                   英国而我要的是: edulevel      nationality
                   高中          中国
                   本科          英国
                   硕士
                   博士
      

  7.   

    你可以这样:
    with combobox1 do 
    begin
      items.clear;
      if not table1.active then
         table1.active:=true;
      Table1.first;
      while not table1.eof then
      begin
         if trim(table1.fieldbyname('nationality').asstring)<>''then
            items.add(table1.fieldbyname('nationality').asstring);
         table1.next;
      end;
    end;
      

  8.   

    万王之王看这里:if combobox1.Items.IndexOf(combobox1.Text) < 0 then
    begin
    table1.insert;
    table1.fieldbyname('nationality').asstring:=combobox1.text;
    table1.post;
    table1.Items.Add(combobox1.Text);
    end;
      

  9.   

    嗯,这样在combobox中空白应该是没了,那往表中添加“英国”是不是也可以没有空白行呢,程序该怎么写呀?
    用table1.fieldbyname('nationality').asstring:=combobox1.text不行的
    即   edulevel      nationality
           高中          中国
           本科          英国
           硕士
           博士 
      

  10.   

    讲不清:
    到底是一个combobox还是二个??
    若是一个combobox装二个字段,当然要“尊重”实际,即一条记录一行
    另:edulevel  nationality
                      高中        中国
                      本科
                      硕士
                      博士
                                  英国
    是什么意思???一行是一条记录吗???
    还是二个combobox分别装edulevel和 nationality字段???看不明白??
      

  11.   

    是两个combobox,分别显示edulevel和nationality.
      

  12.   

    我已经将过了:实际上数据表里已经存在数据了,虽然是空的,所以你做的应该是Edit,而不是insert,insert是往表里添加一条记录!而Edit是在已有记录的基础上修改!