1
A
回答
1
嗯,我不明白爲什麼它是禁止在德爾福行動,但我已經設法在ComponentStyle中創建我自己的查找組合框組件csReplicatable
標誌,它的工作原理!
它沒有經過徹底測試,但在我的應用程序它沒有問題。
Here is the source,看看吧。
-2
我剛剛加了一個TDBLookupCombo
到TDBCtrlGrid
。當我試圖設置ListSource
,我得到了錯誤:
Operation not allowed in a DBCtrlGrid.
因此看來,這是明確禁止的德爾福,所以你將不能夠做到這一點。
0
對於修改/維護修改的VCL/RTL代碼非常沉默,我找到了另一種方法。聲明在單元的接口如下:
interface
uses
...
;
type Tdbp = class(TDBCtrlGrid);
type tdbl = class(TDBLookupControl);
type
TForm4 = class(TForm)
...
DBCtrlGrid1: TDBCtrlGrid;
...
private
...
function FindLCB(DataFieldName: String): TDBLookupComboBox;
procedure FixDBLookupDataLinks;
public
...
end;
...and in your implementation:
----------
implementation
procedure TForm4.FormCreate(Sender: TObject);
begin
...
DBCtrlGrid1.DataSource := DataSource1;
FixDBLookupDataLinks;
end;
procedure TForm4.FixDBLookupDataLinks;
var
lcb: TDBLookupComboBox;
I,n: Integer;
MyDataLink: TDataLink;
ctl: TControl;
dbp: Tdbctrlpanel;
begin
dbp := Tdbp(DBControlGrid1).Panel;
for n := 0 to Pred(dbp.ControlCount) do
begin
ctl := dbp.Controls[n];
if ctl.ClassType = TDBLookupComboBox then
begin
lcb := TDBLookupComboBox(ctl);
lcb.ControlStyle := lcb.ControlStyle + [csReplicatable];
TDBL(lcb).ListLink.DataSourceFixed := False;
for I := 0 to Pred(lcb.ControlCount) do
begin
if lcb.Controls[I] is TPopupDataList then
begin
TDBL(lcb).ListLink.DataSourceFixed := False;
TDBL(lcb).DataLink.DataSourceFixed := False;
MyDataLink := TDataLink(lcb.Controls[I].Perform(CM_GETDATALINK, 0, 0));
if MyDataLink <> nil then
MyDataLink.DataSourceFixed := False;
MyDataLink.DataSource := nil;
end;
end;
end;
end;
end;
function TForm4.FindLCB(DataFieldName: String): TDBLookupComboBox;
var
i: Integer;
begin
Result := Nil;
for i := 0 to Pred(ControlCount) do
if Controls[i].ClassType = TDBLookupComboBox then
if TDBLookupComboBox(Controls[i]).DataField = DataFieldName then
begin
Result := TDBLookupComboBox(Controls[i]);
Break;
end;
end;
0
我發現Embarcadero Developer Network此變通辦法:
I figured out how to work around the issue. Here is a sample. It assumes that the combobox is placed on the grid at design-time, not runtime. So at the moment the event handler is executing, the controls have been streamed successfully from the DFM and links already established. Though one should test in a real project.
procedure TForm1.FormCreate(Sender: TObject); var I: Integer; MyDataLink: TDataLink; begin for I := 0 to DBLookupComboBox1.ControlCount - 1 do if DBLookupComboBox1.Controls[I] is TPopupDataList then begin MyDataLink := TDataLink(DBLookupComboBox1.Controls[I].Perform(CM_GETDATALINK, 0, 0)); if MyDataLink <> nil then begin MyDataLink.DataSourceFixed := False; MyDataLink.DataSource := nil; end; end; end;
Andrei Fomine.
如果您在TDBGrid
有多個TDBLookupComboBox
,您可以使用此代碼段:
procedure TForm1.FormCreate(Sender: TObject);
var
I, C: Integer;
curCombo: TDBLookupComboBox; curDL: TDataLink;
begin
for C := 0 to ComponentCount - 1 do begin
if Components[C] is TDBLookupComboBox then begin
curCombo:= (Components[C] as TDBLookupComboBox);
for I := 0 to curCombo.ControlCount - 1 do
if curCombo.Controls[I] is TPopupDataList then
begin
curDL := TDataLink(curCombo.Controls[I].Perform(CM_GETDATALINK, 0, 0));
if curDL <> nil then begin
curDL.DataSourceFixed := False;
curDL.DataSource := nil;
end;
end;
end;
end;
end;
相關問題
- 1. Java相當於Delphi的DBCtrlGrid?
- 2. dblookupcombobox有一個空行
- 3. 在dbctrlgrid中顯示xml文件內容
- 4. DBLookupComboBox - 如何清除選定的項目?
- 5. 如何更改Delphi中的DBLookupComboBox值?
- 6. DBLookUpComboBox在DBGrid中選定keyvalue編輯表
- 7. 如何使DBLookupComboBox鼠標滾輪工作
- 8. DbLookUpComboBox不允許選擇項目
- 9. dbctrlgrid在運行時刪除並填充條目
- 10. DBLookupComboBox - 如何通過鍵入類似的select2來過濾jquery
- 11. DBLookupcombobox如何使用RAD 2010的Windows 7 Look?
- 12. 我如何獲得適當的項目德爾福DBLookupComboBox要選擇
- 13. 帶和不帶www的HttpContext.Current.User.Identity.Name
- 14. 的fopen帶/不帶@之前
- 15. 帶有邊框的色帶
- 16. 帶領帶的排名書
- 17. 帶有不帶XPath的LINQ的XML
- 18. 帶JPanel和JLabel的帶圖標的JLayeredPane
- 19. 帶註釋的帶格式的SQL
- 20. 帶邊框的帶角度的div
- 21. 的.htaccess相同的URL帶或不帶/
- 22. 帶SSL的郵件的帶寬開銷
- 23. 帶PreConditions的帶格式的SQL
- 24. 播放帶或不帶Flash的嵌入式YouTube視頻,帶或不帶Javascript
- 25. 帶有絲帶的Visual Studio圖像(XML)
- 26. 帶有和不帶Telerik的ASP.NET Ajax
- 27. 帶/不帶命名空間的XML
- 28. 使用帶和不帶AsQueryable的IQueryable()
- 29. 帶導軌的帶寬管理?
- 30. 帶有jqplot的垂直跨度帶
你能否認罪e豐富您的答案,並在信息來源中添加一些關於您的解決方法或一些評論的解釋。如果它適合任何個人使用情況,將更容易實現。謝謝! – bluish