本人刚学习delphi 语言编写程序.
想做一个数据库记录查询修改程序.
我用query组件将查询到的 信息对应到 edit 和 combobox 组件中.
当作修改时用相应的sql 语句修改,当处于查询状态时候将 edit.readonly=true.
请问如何设置combobox 的只读属性呀,比如 combobox中为性别项目(男,女).
请给出解决类似性别项目选择(只读,非只读转换方法选择的思路).
请高手帮忙!!不胜感激.!!!
想做一个数据库记录查询修改程序.
我用query组件将查询到的 信息对应到 edit 和 combobox 组件中.
当作修改时用相应的sql 语句修改,当处于查询状态时候将 edit.readonly=true.
请问如何设置combobox 的只读属性呀,比如 combobox中为性别项目(男,女).
请给出解决类似性别项目选择(只读,非只读转换方法选择的思路).
请高手帮忙!!不胜感激.!!!
解决方案 »
- 调用自定义函数问题:
- ¤●○大伙把平时遇到的隐蔽性错误贴出来共享,防止我们重蹈覆辙,节省我们程序员Debug时间,也为我们的软件发布提高健壮性和稳定性
- DCOM无法启动 的问题。
- 急!请问在Delphi中怎样从VC的Dll文件中导入一个类?
- Stack overflow 的解决办法?
- 哪位大虾有用httpcli或者NMHTTP控件上传文件的例子?你想要多少分我就赠你多少分!!
- synedit组件的使用
- 如何用SQL语言更新和添加memo和BOLB对象?
- 大型通用新闻发布系统合作开发,现在开始报名了! ^_^
- 求救!Kingron(WinAPI)高手同志,请教关于捕获屏幕变化的问题。
- bcd overflow-------dbgrid问题
- 大家知道这是个什么组件吗?可以自动隐藏的
begin
if 查询状态 then
key:=#0;
end;
combobox.enabled;=false;
csDropDownList
添加一个ReadOnly属性,并自己写其read 和write函数就OK了。
要不给你写一个简单的控件。
combobox.enabled;=false;
功能:扩展ComboBox控件的功能,添加一个Only属性 设计者: 谌壮初 技术支持:[email protected] 创建时间:2005-2-2*******************************************************************************}interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TxComboBox = class(TComboBox)
private
{ Private declarations }
FReadOnly :Boolean;
procedure SetFReadOnly(value:Boolean);
function GetFReadOnly:Boolean;
protected
{ Protected declarations }
procedure KeyPress(var Key: Char);override;
procedure KeyDown(var Key: Word; Shift: TShiftState);override; public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy; override;
published
{ Published declarations }
property ReadOnly :Boolean read GetFReadOnly write SetFReadOnly;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Extend UI ', [TxComboBox]);
end;procedure TxComboBox.SetFReadOnly(value:Boolean);
begin
FReadOnly := value;
end;function TxComboBox.GetFReadOnly:Boolean;
begin
Result := FReadOnly ;
end;constructor TxComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;destructor TxComboBox.Destroy;
begin
inherited Destroy;
end;procedure TxComboBox.KeyPress(var Key: Char);
begin
if GetFReadOnly
then Key :=#0
else inherited;
end;procedure TxComboBox.KeyDown(var Key: Word; Shift: TShiftState);
begin
if GetFReadOnly
then Key :=0
else inherited;
end;end.以上代码完全正确
begin
if 查询状态 then
key:=#0;
end;当是需求状态的时候就把按键值为空
我一向都是这样做的呵呵,要不就象上面说的procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if 查询状态 then
key:=#0;
end;
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if 查询状态 then
combobox.style:=csDropDownList;
end;
一楼 和二楼的兄弟方法都很好,你别吓卖弄风骚,人家楼主只不过刚接触delphi你装个屁啊?????????