在onchange事件中
if combobox.items.indexof('xxx') <> -1 then
combobox.itemindex := combobox.items.indexof('xxx')
if combobox.items.indexof('xxx') <> -1 then
combobox.itemindex := combobox.items.indexof('xxx')
解决方案 »
- 请问各位,如何将一个窗口只显示在指定的窗口上。请帮助。
- 求一Delphi正则表达式,过滤出网页中的域名,在线等
- 我想做个“淘宝旺旺”样式的软件界面,有可以参考的代码吗?谢谢!
- [高分求助]Mediaplayer制作的MP3播放器为什么在一些电脑上播放出来的是噪音,来者有分呀!
- Delphi错误,请大家帮忙解决
- ????????????????????????????????????
- 怎样取随机数?(在线等待)
- 哪位大侠有绝活,能改资源字符串
- 这几天写了一个全局hook mouse、键盘的程序,结果发现hook用在这个程序中太多
- 再问一次:可不可以用scrollbar之类的东西控制techart的页数(X轴的进度)?
- 关于报表的简单问题,急!
- win2000中的图片预览如何设置回来?
发过来我帮助你搞定
[email protected]
BCB语法,请参考。
(private : WORD key;)
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
String value = ComboBox1->Text ; // If the user tried to delete he must not want to change anything.
if (lastkey == '\b' || lastkey == VK_DELETE)
{
lastkey = 0 ;
return ;
}
lastkey = 0 ;
// Make sure the user is not typing something in the middle or else
// proceeding will make the caret jump.
if (ComboBox1->SelStart != value.Length ())
return ; // Find the item matching text in the dropdown.
int index = SendMessage (ComboBox1->Handle, CB_FINDSTRING, -1, (LPARAM) value.c_str ()) ;
if (index >= 0)
{
// There was a match so now set up the selected text.
ComboBox1->ItemIndex = index ;
String newtext = ComboBox1->Text ;
SendMessage (ComboBox1->Handle, CB_SETEDITSEL, 0, MAKELPARAM (value.Length (), -1)) ;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
// Save the last key pressed.
lastkey = Key ;
}
在delphi中两个sendmessage应如何设,CB_FINDSTRING,CB_SETEDITSEL是不是在 window.pas中有 是&H14c 和 &H14F吗?下列代码应如何改正? procedure TForm1.ComboBox1Change(Sender: TObject);
var value:string;
index:integer;
newtext:string;
str:string;
begin value:=combobox1.Text;
if combobox1.SelStart<>length(value) then
exit;
str:=copy(combobox1.Text,0,combobox1.SelStart);
{if combobox1.items.indexof('''+combobox1.text+''') <> -1 then
combobox1.itemindex := combobox1.items.indexof('''+combobox1.text+''');}
index:=SendMessage (ComboBox1.Handle, CB_FINDSTRING , -1, str.asstring ) ;
if index>0 then
ComboBox1.ItemIndex := index ;
newtext := ComboBox1.Text ;
SendMessage (ComboBox1.handle,CB_SETEDITSEL , 0, MAKELPARAM (LENGTH(VALUE),-1)) ;end;