Mega Code Archive

 
Categories / Delphi / System
 

How to copy cell value to clipboard

Title: How to copy cell value to clipboard? Question: How to copy cell value to clipboard by typing the code inside Execute event of TAction? Answer: Sometimes, we have to make faster in copiying the information from Grid to the clipboard. I'm as a programmer that often to use a technique to assign the event of the TComponent manually. I always avoid type the code to the TComponent by double clicking the event of TComponent. So, this technique make me to assign the method to the event of TComponent manually. I know that this technique consume more efforts than I double click the event of TComponent. But, there are advantage of this technique, I can assign a event to multi-component and I can copy paste the component in the form more quickly, because I do not afraid anymore. Why? that is right, If we copy the Tcomponents from TForm that one or more event already assigned, so all of properties and events also copied. So, we have to remove it manually and this process also consume the efforts more. Okay, back to the topic. In this article, I want to use TNextDBGrid as the object to be reviewed. It's time to for us to work with more faster in programming. Of course, by having much trick for handling much cases, we will have high productivity in producing the product or make the project more faster to be finished. As I said like as the title of this article that I will share my technique in getting the information in the cell of TNextDGGrid and copy it into the clipboard. If we want to copy the cell value of TNextDBGrid from the event inside of it, so we can do this process easily, the problem is, how to do this process from another place. For an example is TAction. How we can do that by typing the code in Execute event of TAction? By this article, I will show you how to realize it process easily. If you are courious about how to do that, let you look this code: [CODE]procedure TForm1.Action1Execute(Sender: TObject); begin with Sender as TNextDBGrid do begin Clipboard.AsText := Cells[SelectedColumn, SelectedRow]; end; end;[/CODE] Don't forget to add [B]Clipbrd[/B] on interface or implementation. I hope this article can help you in copying the information from the cell. At the last, I hope this article does not make you confuse :) If you so, please do not read this article and close this article from tab of your browser. Regards, Eko Indriyawan