Hi
I use a chart to show some series and a chart grid to show the values of the series. Now I would like to copy the selection to the clipboard if the user has selected some rows and columns of the chart grid. There is a complication that I hide some columns by setting the width to zero and I don't want that these colums are copied.
I could read begin and end of rows and columns with Selection.Rigth, Left, Top and Bottom but I don't see how to access the values in the cells. I guess that I have to access the corresponding series and use XValue and YValue.
Thanks, Rolf
How copy selection in TChartGrid to clipboard
-
- Newbie
- Posts: 18
- Joined: Fri Nov 15, 2002 12:00 am
Re: How copy selection in TChartGrid to clipboard
Hello,
You can use a helper to access the protected GetEditText(ACol,ARow) function:
Then you'll be able to do later:
You can use a helper to access the protected GetEditText(ACol,ARow) function:
Code: Select all
type TCustomChartGridHelper = class helper for TCustomChartGrid
public
function GetText(ACol, ARow: Integer): String;
end;
function TCustomChartGridHelper.GetText(ACol, ARow: Integer): String;
begin
result:=GetEditText(ACol,ARow);
end;
Code: Select all
procedure TForm1.ChartGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i: Integer;
tmpS: string;
begin
tmpS:='';
if (ssCtrl in Shift) and (Key=Ord('C')) then
begin
for i:=0 to Length(selectedCells)-1 do
tmpS:=tmpS + ' ' + ChartGrid1.GetText(selectedCells[i].X, selectedCells[i].Y);
ShowMessage(tmpS);
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 18
- Joined: Fri Nov 15, 2002 12:00 am
Re: How copy selection in TChartGrid to clipboard
Thanks Yeray for the prompt answer!
But I don't know how to define a helper class under C++.
I need to code in C++ with C++Builder.
I will see if I can find a workaround to access the protected GetText(ACol,ARow) function under C++.
I could not find a method GetText in the header file TeeChartGrid.hpp. Is it GetEditText? Because at the beginnning you wrote GetEditText but GetText in the code.
Also, I could not find a property selectedCells (looks like Java code definition). Do you mean Selection?
Rolf
But I don't know how to define a helper class under C++.
I need to code in C++ with C++Builder.
I will see if I can find a workaround to access the protected GetText(ACol,ARow) function under C++.
I could not find a method GetText in the header file TeeChartGrid.hpp. Is it GetEditText? Because at the beginnning you wrote GetEditText but GetText in the code.
Also, I could not find a property selectedCells (looks like Java code definition). Do you mean Selection?
Rolf
-
- Newbie
- Posts: 18
- Joined: Fri Nov 15, 2002 12:00 am
Re: How copy selection in TChartGrid to clipboard
I found a workaround for C++:
I edited the header file TeeChartGrid.hpp and moved
DYNAMIC AnsiString __fastcall GetEditText(int ACol, int ARow);
from protected to public.
Then the compiler didn't complain anymore that GetEditText is not accessible.
Surprisingly the linker didn't complain and the code works fine!
But are there any drawbacks by this hack? I'm surprised that this is working!!
Why is GetEditText protected?
Regards, Rolf
I edited the header file TeeChartGrid.hpp and moved
DYNAMIC AnsiString __fastcall GetEditText(int ACol, int ARow);
from protected to public.
Then the compiler didn't complain anymore that GetEditText is not accessible.
Surprisingly the linker didn't complain and the code works fine!
But are there any drawbacks by this hack? I'm surprised that this is working!!
Why is GetEditText protected?
Regards, Rolf
Re: How copy selection in TChartGrid to clipboard
Hello Rolf,
http://docwiki.embarcadero.com/Librarie ... etEditText
Looking at this, I'm not sure if this is possible in C++.Rolf Fankhauser wrote: But I don't know how to define a helper class under C++.
I need to code in C++ with C++Builder.
The TCustomChartGridHelper helper I defined declares the method GetText (it could be any name of your choice) and it calls the protected method GetEditText.Rolf Fankhauser wrote:I could not find a method GetText in the header file TeeChartGrid.hpp. Is it GetEditText? Because at the beginnning you wrote GetEditText but GetText in the code.
selectedCells was an array of points (int, int) I used to test that. The intention is to store the row and column of the selected cells. You could use OnMouseDown to populate that array (adding or removing points to it) when a cell is clicked (probably when Ctrl key is also pressed).Rolf Fankhauser wrote:Also, I could not find a property selectedCells (looks like Java code definition). Do you mean Selection?
If that works I don't see any problem with that.Rolf Fankhauser wrote:Then the compiler didn't complain anymore that GetEditText is not accessible.
Surprisingly the linker didn't complain and the code works fine!
But are there any drawbacks by this hack? I'm surprised that this is working!!
It overrides the GetEditText protected method from its parent, the TCustomGrid:Rolf Fankhauser wrote:Why is GetEditText protected?
http://docwiki.embarcadero.com/Librarie ... etEditText
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |