大哥:快给小弟灌水
热门软件下载:
? 1:如何在dbgrid控件中实现某个field的类似单选按钮的功能。
2 将dbgrid的某列的buttonstyle设置为cbsauto;如何在下拉框中实现对另外一个数据表的调用(即在下拉框中显示另外一个表)。
请给出详细代码。
谢!!!!!!!!!!!!!!!!!!!
推荐阅读
再灌水
不大明白你的意思
给你段代码吧!
dbgrid镶入dbcombobox
void __fastcall tform1::dbgrid1drawdatacell(tobject *sender,
const trect &rect, tfield *field, tgriddrawstate state)
{
if(state.contains(gdfocused))
if(field->fieldname==dbcombobox1->datafield)
{
dbcombobox1->left=rect.left+dbgrid1->left;
dbcombobox1->=rect.top+dbgrid1->;
dbcombobox1->width=rect.right-rect.left;
dbcombobox1->height=rect.bottom-rect.top;
dbcombobox1->visible=true;
}
}
//---------------------------------------------------------------------------
void __fastcall tform1::dbgrid1colexit(tobject *sender)
{
if(dbgrid1->selectedfield->fieldname==dbcombobox1->datafield)
dbcombobox1->visible=false;
}
//---------------------------------------------------------------------------
void __fastcall tform1::formcreate(tobject *sender)
{
while (!table1->eof)
{
dbcombobox1->items->add(table1->fieldbyname("name")->asstring);
table1->next();
}
table1->first();
}
//---------------------------------------------------------------------------
void __fastcall tform1::dbgrid1keypress(tobject *sender, char &key)
{
if(key!=13)
if(dbgrid1->selectedfield->fieldname==dbcombobox1->datafield)
dbcombobox1->setfocus();
//sendmessage(dbcombobox1->handle,wm_char,word(key),0)
}
dbgrid1自己可以产生combobox的下拉列表框
楼主,你的第一个功能用第三方控件吧!
比如ehlib等。
你的第二个问题,除了阿星的方法还有一个就是新建一个查找的字段。
说是比较难说明的。
你要是知道我是怎么搞。
你发信息给我吧!
相关评论