請問DBGrid如何讓欄位自動下拉展開? |
尚未結案
|
a_wai520
一般會員 發表:6 回覆:5 積分:2 註冊:2004-06-17 發送簡訊給我 |
請問DBGrid如何讓欄位自動下拉展開?也就是移到該欄時(ColEnter)
能夠自動展開讓你選(picklist).而不用再以滑鼠去按那個倒三角形
.謝謝 也有參照其它例子
需再DBGrid-->ColEnter Event 輸入
if DBGrid2.SelectedField.FieldName='Song_type' then
begin
keybd_event(VK_F2, MapVirtualKey(VK_DOWN, 0), KEYEVENTF_KEYUP, 0); keybd_event(VK_F2,0,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
keybd_event(VK_DOWN, MapVirtualKey(VK_DOWN, 0), 0, 0);
keybd_event(VK_DOWN, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
end;
end; 問題一
假設已輸入5筆資料
現在游標要往上or往下編輯DBGrid欄位時,就無法自動下拉展開
|
deity
尊榮會員 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
a_wai520您好: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, Grids, DBGrids; type myGrid = class(TCustomGrid) end; type myInplaceEditList = class(TInplaceEditList) end; type TForm1 = class(TForm) DataSource1: TDataSource; DBGrid1: TDBGrid; Query1: TQuery; procedure DBGrid1ColEnter(Sender: TObject); procedure Query1AfterScroll(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} //光标左右移动 procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin if DBGrid1.SelectedIndex = 1 then begin DBGrid1.Options := DBGrid1.Options [dgAlwaysShowEditor]; myInplaceEditList(myGrid(DBGrid1).InplaceEditor).DropDown; DBGrid1.Options := DBGrid1.Options - [dgAlwaysShowEditor]; end; end; //光标上下移动 procedure TForm1.Query1AfterScroll(DataSet: TDataSet); begin if DBGrid1.SelectedIndex = 1 then begin DBGrid1.Options := DBGrid1.Options [dgAlwaysShowEditor]; myInplaceEditList(myGrid(DBGrid1).InplaceEditor).DropDown; DBGrid1.Options := DBGrid1.Options - [dgAlwaysShowEditor]; end; end; end. 因DBGrid的PickList是通过TDBGridInplaceEdit.DropDown,所以可以继承TInplaceEditList进行调用,试试看 >> ——行径窄处,留一步与人行—— 發表人 - |
sl@cableplus.com.cn
高階會員 發表:168 回覆:359 積分:130 註冊:2004-03-26 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |