> I would like to be able to select text in a TDBcombobox and copy/cut
> it to the clipboard using a menu command. Conversely, I would
like to
> be able to paste into a TDBcombobox via menu. I have not been
able to
> figure out how to get this object and the clipboard to communicate
> with each other.
>
> The application I'm working on is a source code library database
> browser. It has a memo field to hold snippets of code that
I might
> want to reuse. One of the other fields is the language to which
the
> code applies. I'm using a combobox for this field, since the
list of
> languages is pretty short but might be extended later. I'm
trying to
> implement consistent copy-cut-paste commands among all the fields
on
> the form, using both keyboard and menu commands. Does this
make it
> any clearer? Am I simply missing something obvious? (It
wouldn't be
> the first time!)
>
> Dav Vandenbroucke
> Economist
> U.S. Dept. HUD
> david_a._vandenbroucke@hud.gov
The TComboBox and TDBComboBox controls' inheritance hierarchy doesn't
include the TCustomEdit control wherein the CopyToClipboard and
PasteFromClipboard methods are implemented, so you can't get at that
functionality that way.
You could drop down to the Clipboard API calls to make this happen;
but
if you want a strictly VCL solution, you could also do something like
this for copying:
-------------------->8 cut here 8<--------------------
procedure TForm1.CopyComboItemToClipboard( Combo : TComboBox ) ;
var
TempEdit : TEdit ;
begin
TempEdit := TEdit.Create( self ) ;
TempEdit.Parent := Combo.Parent ;
TempEdit.Text := Combo.Text ;
TempEdit.SelectAll ;
TempEdit.CopyToClipboard ;
TempEdit.Free ;
end ;
-------------------->8 cut here 8<--------------------
Pasting is a different situation; normally ComboBoxes provide a
pre-defined set of options. What do you want to do on a Paste
operation
if the pasted text doesn't already exist in the ComboBox? Add
it to the
list? Find the nearest match?