谁有dbctrlgrid使用的经验分享一下。
主要是在每个面板(panle)中可以按不同的条件显示不同的颜色以方便区分
找了半天没找见合适的方法。网上曾有人提过,不过都没有人说得比较清楚。
请有经验的高手说说看。高分相送,急。

解决方案 »

  1.   

    OnPaintPanel事件
    procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid;
      Index: Integer);  if DBCtrlGrid.PanelIndex=index then
        DBCtrlGrid.Color := clBlue
      else if index=1 then
        DBCtrlGrid.Color := clWhite
           else
             DBCtrlGrid.Color := clRed;  DBCtrlGrid.Canvas.FillRect(rect(0, 0, DBCtrlGrid.PanelWidth, DBCtrlGrid.PanelHeight));
    從幫助看應該是這樣寫,實際上好像有點問題
    因為傳進來的參數index不是實際的格的序號
    第二格是0, 第三格是1,第一格的index卻是最後一格的減1
    如你有6格,那麼第一格就是5
    index代表控件上的第幾個格 
      

  2.   

    procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid;
      Index: Integer);
    begin
      if Index=1 then
        DBCtrlGrid.Color := clWhite   else
             DBCtrlGrid.Color := clRed;
    DBCtrlGrid.Canvas.FillRect(rect(0, 0, DBCtrlGrid.PanelWidth, DBCtrlGrid.PanelHeight));
    end;設定第三格是白色
    其他的是紅色 
      

  3.   

    我还没试上面仁兄的方法。可能是我没说清楚。
    我在每个panel上会放一个dbtext,我是通过断别dbtext.caption的值来变相应的颜色
    我的条件是这样的:if dbctrlgrid."指定的panel"."指定的dbtext".值='A' then
       DBCtrlGrid.Color := clRed
    else if dbctrlgrid."指定的panel"."指定的dbtext".值='B' then
       DBCtrlGrid.Color := clWhite
    else if ....请问楼上仁兄,这样有办法吗?我关键不知道这个"指定的panel"."指定的dbtext"
    怎么表示。谢谢各位,请知道的高手都来看看。