现在整个项目就差这个问题,本来应该在需求时就需要攻关的,但因为客户到最后才提出问题.
客户需要在DBGRID网格中的任一网格及每个网格中的任一个或几个字符都可以设置颜色,就像EXCEL中单元格文字可以设置颜色,而且一个单元格可以设置多种颜色.这需要怎样才能做到?
如果要单纯从代码实现可能会比较难.不知道有没有人知道有什么控件可以实现的?数据存储格式或者方式可能也都要变,原来数据是存在ACCESS数据库中的.
客户需要在DBGRID网格中的任一网格及每个网格中的任一个或几个字符都可以设置颜色,就像EXCEL中单元格文字可以设置颜色,而且一个单元格可以设置多种颜色.这需要怎样才能做到?
如果要单纯从代码实现可能会比较难.不知道有没有人知道有什么控件可以实现的?数据存储格式或者方式可能也都要变,原来数据是存在ACCESS数据库中的.
这二种控件十分好用,你可以去下,CX,DX系列的工具是我见过的最好最强的数据处理工具,Ehilb也是个不错的数据处理工具,比CX,DX系列的工具要简单点。
颜色想怎么换就怎么换,什么效果都能实现!
var
i: integer;
BorderHeight: integer; // 边框高度
BorderRect: TRect; // 边框坐标
HighSubLow: Single; // 最高价与最低价的差额
MaxVir: Single; // 边框高×最大值
yMax,yMin,yOpen,yClose:integer; //最高价, 最低价, 开盘价, 收盘价
begin
inherited;
FDrawHisData := TDrawHisData.Create;
BorderHeight := ClientHeight; // 边框长度
BorderRect := ClientRect; // 边框坐标
highSubLow := FDrawHisData.getMaxVolume - FDrawHisData.getMinVolume;
if (highSubLow < 0) or (BorderHeight<0) then
Exit;
FCell.width :=10;
MaxVir := BorderHeight * FDrawHisData.getMaxVolume;
FCell.middle := BorderRect.Left + FCell.width div 2;
FCell.left := BorderRect.Left;
FCell.right := BorderRect.Left + FCell.width;
for i := low(FDrawHisData.HistoryPxList) to high(FDrawHisData.HistoryPxList) do
begin
with FDrawHisData.HistoryPxList[i] do
begin
yMax := BorderRect.Top + Round((MaxVir - BorderHeight * HighPx) / HighSubLow);
yClose := BorderRect.Top + Round((MaxVir - BorderHeight * ClosePx) / HighSubLow);
yOpen := BorderRect.Top + Round((MaxVir - BorderHeight * OpenPx) / HighSubLow);
yMin := BorderRect.Top + Round((MaxVir - BorderHeight * LowPx) / HighSubLow);
if FDrawHisData.HistoryPxList[i].ClosePx-FDrawHisData.HistoryPxList[i].OpenPx >= 0 then
begin //涨
uDrawUtils.VertLine(self.Canvas,FCell.middle, yMax, yClose, upColor);
if yClose <> yOpen then
uDrawUtils.FrameRect(self.Canvas,FCell.left,yClose,FCell.right,yOpen,UpColor)
else
begin
//画条横线
end;
uDrawUtils.VertLine(self.Canvas,FCell.middle, yOpen, yMin, upColor);
end else
begin //跌
uDrawUtils.VertLine(self.Canvas,FCell.middle, yMax, yClose, downColor);
if yClose <> yOpen then
uDrawUtils.FillRect(self.Canvas,FCell.left,yOpen,FCell.right,yClose,DownColor)
else
begin
//画条横线
end;
uDrawUtils.VertLine(self.Canvas,FCell.middle, yClose, yMin, downColor);
end;
end; //end with
FCell.middle := FCell.middle + FCell.width;
FCell.left := FCell.left + FCell.width;
FCell.right := FCell.left + FCell.width;
end;
FDrawHisData.Free;
end;
画股票蜡烛线的示例,呵呵!