我实现它既不可写,又要有text
我尝试加入
procedure   Tform.button1click(sender:object);   
  begin   
  combobox1.itemindex:=0;   
  end;   
    但是不成功,在线等

解决方案 »

  1.   

    用了combobox1.Style:=csOwnerDrawVariable;
    我的赋值语句combobox1.Style:=csOwnerDrawVariable;就失效了我想又可以显示text的属性,又不能随便被改,包括用下拉的选择都不可以的那种
      

  2.   

    你输入在combobox的items中固定的几个值之后)选择style属性中的csDropDownlist这个就好了
      

  3.   

    你输入在combobox的items中固定的几个值之后选择style属性中的csDropDownlist这个就好了
      

  4.   

    把控件实效不可以吗?
    combobox1.Enabled := false;
      

  5.   

    楼上的方法不行的,如果是这样,就不能进行选择了,那样还不如用EDIT,何必用COMBOBOX呢?style属性设为csDropDownlist
    然后根据Itemindex来选择值
      

  6.   

    procedure TForm4.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    begin
      key:=#0;
    end;
      

  7.   

    不过,用鼠标粘贴就会出现问题了。
    或者
    可以在Combobox的外面再加一个略小一点的Edit,设置一下它的属性,然后在Combobox取得焦点时显示,
      

  8.   

    procedure TForm1.FormCreate(Sender: TObject);
    var
      h : HWND;
    begin
      h :=  findwindowex(combobox1.Handle, 0, nil, nil);
      if h > 0 then
        SendMessage(h, EM_SETREADONLY, 1, 0);
    end;//还要处理退格键,因为它被combobox拦截了
    procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    begin
      if Ord(key) = 8 then key := #0;
    end;
      

  9.   

    设置为Style为csSimple,并且加事件过滤掉键的输入。------------------------------procedure TForm1.FormCreate(Sender: TObject); 
    var 
      h : HWND; 
    begin 
      h :=  findwindowex(combobox1.Handle, 0, nil, nil); 
      if h  > 0 then 
        SendMessage(h, EM_SETREADONLY, 1, 0); 
    end; 我之前试过这样是不行的,如果能通过消息设,ComboBox就会直接封装个属性给你了。
      

  10.   

    收回上贴关于消息的说法,之前确实不行,估计可能是没有FindWindowEx的缘故 -_-
      

  11.   

    将属性Style设为csDropDownlist就行了,选择时只要根据ItemIndex获取,
    将控件失效的方法固然可以让combobox只读...但那样就失去了combobox的选择意义了...还不如用edit
      

  12.   

    将属性Style设为csDropDownlist就行了,选择时只要根据ItemIndex获取, 
    将控件失效的方法固然可以让combobox只读...但那样就失去了combobox的选择意义了...还不如用edit
    ----------------------------------------------------------------------------------
    同意LS!
      

  13.   

    将属性Style设为csDropDownlist就行了,选择时只要根据ItemIndex获取, 
    将控件失效的方法固然可以让combobox只读...但那样就失去了combobox的选择意义了...还不如用edit
    -----------------------------------------------------------------------------------
    这个方法固然是可以用鼠标选择,但是无法用程序赋初始值的
      

  14.   

    procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key<>#0 then
       key:=#0;
    end;
    可以控制键盘的输入//如果不是空的,就不让输入,,,
      

  15.   

    procedure TForm4.ComboBox1KeyPress(Sender: TObject; var Key: Char); 
    begin 
      key:=#0; 
    end;-----------------------------------------------------------------------------
    同意
      

  16.   

    设置好items,然后设置style类型就可以了!