お世話になります。
過去ログを見たのですが、原因が分からないので教えてほしいです。
一部抜き出しですが…
------------------------------------
------------------------------------
type
TForm1 = class(TForm)
…
procedure ComboBox1Select(Sender: TObject);
function UFCreate_ComboBox(StrGrid: TStringGrid): Boolean;
var
parCBox : array of TComboBox;
…
procedure TForm1.ComboBox1Select(Sender: TObject);
var
iCnt : Integer;
iCmpNo : Integer;
CBox : TComboBox;
begin
try
CBox := (Sender as TComboBox);
if CBox.Text = 'A' then begin
...処理
end;
...
function TForm1.UFCreate_ComboBox(StrGrid: TStringGrid): Boolean;
begin
try
Inc(piCnt_CBox);
Inc(piRow_Cnt); // RowCount
SetLength(parCBox, piCnt_CBox + 1);
parCBox[piCnt_CBox] := TComboBox.Create(Self);
// イベントハンドラの割り当て
parCBox[piCnt_CBox].OnSelect := ComboBox1Select; // 選択処理
parCBox[piCnt_CBox].OnChange := ComboBox1Change; // 文字列が変更された時の処理
// コントロールの親を設定
parCBox[piCnt_CBox].Parent := StringGrid1;
------------------------------------
------------------------------------
上記のように、StringGridの上にComboBoxを動的生成しています。
ComboBoxを生成する処理の中にイベントを割り当てる処理を書いていますが、
ComboBoxのOnSelectイベントに飛びません。
同じ様な処理でフォームの上に動的生成したComboBoxは
イベントに飛びます。
StringGridの上というのがなにか問題なのでしょうか?
お知恵をいただきたいです。
よろしくお願いします。
ちなみに、
parCBox[piCnt_CBox].OnChange := ComboBox1Change; // 文字列が変更された時の処理
は無視してください。
よくわからんが
ListBox ComboBox は Parent を StringGrid や DrawGrid にすると
CNCommand が飛んでこないみたい
Edit Memo も OnChange 飛んでこないし
CheckBox なんて チェックが付けられない・・・・
原因は・・・・
procedure TCustomGrid.WMCommand(var Message: TWMCommand);
begin
with Message do
begin
if (FInplaceEdit <> nil) and (Ctl = FInplaceEdit.Handle) then
case NotifyCode of
EN_CHANGE: UpdateText;
end;
end;
end;
に inherited; が無い・・・・
BDS2006 XE2 ともに・・・
XE3を使ってるのですが、vcl.Grids.pasの
procedure TCustomGrid.WMCommand(var Message: TWMCommand);
に inherited;を入れたらイベントが通りました。
思い通りの動作ができました。助かりました。
ありがとうございました。
ツイート | ![]() |