我想在combobox中显示时显示汉字,而传递参数时传递的是对应的value,就像在html中的select下拉框一样,<select name=a><option value=1>天津</option>..

解决方案 »

  1.   

    这样加入的不就只有一列值呀,跟我“就像在html中的select下拉框一样,<select name=a><option value=1>天津</option>..”这个功能不符
      

  2.   

    我想楼主的意思应该是这样:
    比如在combobox下显示的是
    天津
    上海但写进数据库的是
    1
    2我用第三方控件wwDBcombobox
    wwDBcombobox.Items.Add('天津'+#9+'1');
    用combobox我试试有什么办法
      

  3.   

    如果是这样,,何必用第三方控件!!
    用COMBOX.ITEMINDEX就可以了!!!
    请楼主说明白!!
      

  4.   

    建议你另外添加一个Tstrings变量,让他与combobox1.items同步,就可以了!
      

  5.   

    这个问题也用问阿!看样子,你对VCL不熟悉哈。建议两本VCL方面的书吧。
      

  6.   

    看来我没说明白,就是combobox的显示和取值问题
      

  7.   

    显示中文取值用 combox.itemindex属性,,它记录显示中文的位置!to:  pacificlh(pacificlh) :大家都是朋友, ,有话好好说
      

  8.   

    你在form中放一个combobox和两个edit,edit1用来显示名称(上海,北京,天津等),edit2用来显示值;
    在combobox的onclick属性中写:
        edit1.Text:=combobox1.Text;
        edit2.Text:=inttostr(combobox1.itemindex);如果上海,北京,天津对应的值为a,b,c,那应该这样吧:
    combobox的onclick属性中写:
       case combobox1.intemindex of
       0:
          edit1.text:=combobox1.text;
          edit2.text:='a';        我没有理解错吧?!
      

  9.   

    我觉得用DBLookupCombobox不是更好吗
    是不是这样?
      

  10.   

    dnlookupcombobox是连接数据库的..当然用也可以
      

  11.   

    我是说从数据库中提显示和值像这样
    q:=TQuery.Create(nil);
    q.DatabaseName:=districtinfo.alldistrict.Query1.DatabaseName;
    q.SQL.Clear;
    q.SQL.Add('select class_category_id,class_category_name from yzwx_class_category where jibie=:jibie');
    q.ParamByName('jibie').AsInteger:=1;
    q.Open;
    while (not q.Eof) do
    begin
    aclass_category_id:=q.Fields.Fields[0].AsString;
    aclass_category_name:=q.Fields.Fields[1].AsString;
    combobox1.Items.AddObject(aclass_category_name,TObject(aclass_category_id));
    q.Next;
    end;
    在combobox1的onchange事件中procedure Taddclasscategory.combobox1Change(Sender: TObject);
    var aclass_category_id:integer;
    q:TQuery;
    beginaclass_category_id:=strtoint(string(combobox1.Items.Objects[combobox1.ItemIndex]));
    q:=TQuery.Create(nil);
    q.DatabaseName:=districtinfo.alldistrict.Query1.DatabaseName;
    q.SQL.Clear;
    q.SQL.Add('select max(class_category_id) as a from yzwx_class_category where parent_classcategory_id=:parent_classcategory_id');
    q.ParamByName('parent_classcategory_id').AsInteger:=aclass_category_id;
    q.Open;
    if(q.Fields.Fields[0].AsInteger<>0) then
    class_category_id.Text:=inttostr(q.Fields.Fields[0].AsInteger+10)
    else
    begin
    class_category_id.Text:=inttostr(aclass_category_id+10);
    end;
    end;而程序报access violation错误,不知为什么
      

  12.   

    我也出现了同样的错误!不知道为什么?但是我在其他的机子上试过,object的结果是乱码.倒是没有出现错误。
    up!up!
      

  13.   

    在这里出现错误!
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
      showmessage(string(combobox1.Items.Objects[combobox1.ItemIndex]));;
    end;
      

  14.   

    for i:=0 to AdoQuery1.RecordCount-1 do
    begin
    //如果这样就没有错误。
      ItemValue:='item';
    //但是这样  ItemValue:='item'+inttostr(i);就有错。
      ComboBox1.Items.AddObject(AdoQuery1.Fields.Fields[0].text,TObject(ItemValue));
      if not AdoQuery1.Eof then
            AdoQuery1.Next;
    end;
      

  15.   

    To: eddianliu(百无聊赖)
    什么意思?