掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridに任意のコンポーネントを貼るには? (ID:6938)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じでどうでしょう procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var SetStr:string; Header:LongInt; begin SetStr := StringGrid1.Cells[ACol,ARow]; if (gdFocused in State) then begin SetWindowPos(ComboBox1.Handle,0, Rect.Left+StringGrid1.Left+1, Rect.Top+StringGrid1.Top+1, Rect.Right-Rect.Left+2, Rect.Bottom-Rect.Top+2, SWP_NOZORDER or SWP_SHOWWINDOW); ComboBox1.Text := SetStr; ComboBox1.Show; Exit; end; if ComboBox1.Visible then ComboBox1.Visible := False; StringGrid1.Canvas.FillRect(Rect); if ARow = 0 then Header := (DT_CENTER or DT_VCENTER or DT_SINGLELINE) else Header := (DT_SINGLELINE or DT_VCENTER or DT_LEFT); DrawText(StringGrid1.Canvas.Handle, PChar(SetStr),Length(SetStr), Rect,Header) end; procedure TForm1.FormShow(Sender: TObject); begin ComboBox1.Visible := False; end; procedure TForm1.FormCreate(Sender: TObject); begin StringGrid1.DefaultRowHeight := ComboBox1.Height-StringGrid1.GridLineWidth; end; procedure TForm1.ComboBox1Change(Sender: TObject); begin With StringGrid1 do begin Cells[Col,Row] := ComboBox1.Text; end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.