大家看一下这个表格用的是哪个控件呢?

解决方案 »

  1.   

    貌似是DBGrid。
    不过要实现复杂功能,用cxGrid会简单点。
      

  2.   

    初步判断这是个cxGrid控件
      

  3.   

    DBGRIDEH 或者CXGRID都可以实现
      

  4.   

    刚刚那帖子的功能和这个应该也差不多了吧,cxgrid,wwdbgrid,dbgrideh应该都是可以的,这三个是我用过功能比较完善的,但是完全一样不容易
      

  5.   

    现在使用DBGridEh实现上图效果时遇到的问题主要是两个
    1.是如何增加“行号”两个字。
    2.是如何实现,单击(只需单击一次,而不是先单击使其获得焦点然后再次单击一次)某个单元格时,a.单元格所在的行整行为深蓝色选中状态,b.选中的单元格背景色为白色。(如上图所示)
    如果将RowSelect属性设置为True的话,可以选择整行,但是Edit属性会自动变为False,即不能编辑单元格。目前剩余20分了,等其他帖子结贴返还分数后,再给大家补上!
      

  6.   

    第二个是设置DBGRIDEH的OPTIONS属性dgalwayshowEditor=true就可以了
    要改这个颜色,还还得加上这个代码了,高亮的颜色没有相应属性设置,也得改源代码吧
    procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumnEh;
      State: TGridDrawState);
    begin  with TStringGrid(DBGrideh1) do begin
        if row = MouseCoord(Rect.Left+1, Rect.Top+1).Y then
        begin
          Canvas.Brush.Color := clMenuHighlight;
          Canvas.Font.Color := clWhite;
        end;
      end;
    end;第一个,等下再试
      

  7.   


    if DataCol=0 then
      begin  DBGridEh1.Canvas.Brush.Color:=clBtnFace;
      DBGridEh1.Canvas.Font.Color:=clBlack;
      DBGridEh1.Canvas.TextOut(0,0,'行号');  DBGridEh1TitleClick(DBGridEh1.Columns[0]);
      DBGridEh1.Canvas.TextOut(Rect.Left-10,Rect.Top+3,IntToStr(DBGridEh1.DataSource.DataSet.RecNo));
      end;加上红色代码就可以了,,位置调整TextOut(0,0,'行号');两个00的值
      

  8.   

    问题
    1.(每列的TitleButton属性设置true后)单击任意一列的列头,“行号”两个字会消失。(每列的TitleButton属性设置true后)
    2.当列较多时,拖动水平滚动条,隐藏第一列后,这种情况下,单击任意行,行号会消失,然后单击其他行后,上次单击的行的行号也不会显示。
      

  9.   

    这个问题确实难弄,即使是其它控件也比较难实现这种功能吧,CXGRID试试?
    我的软件做法都是在最下面状态栏里显示行号的***
      

  10.   

    谢谢case5166的关注用Spy++跟踪了一下,下面的这个控件是用的Cxgrid
    现在我已经实现了在cxgrid的Indicator中增加行号的功能了,但是不知道如何在显示行号的同时保留原来的三角形。
      

  11.   

    请问楼主如何在Indicator中显示行号?
      

  12.   

    抱歉,手头上暂时没有装CXGRID,,,
      

  13.   

    感谢楼上各位朋友的关注。现总结如下:1.该控件使用的是cxgrid2.在Indicatoer列显示每行序号的方法如下procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
      Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    var
      AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
      ATextRect: TRect;
      X, Y: Integer;
    begin
      if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then Exit;
      ATextRect := AViewInfo.ContentBounds;
      AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
      InflateRect(ATextRect, -2, -1);
      if AIndicatorViewInfo.GridRecord.Selected then  //如果是选中的行号则Indicatoer字体加粗
      begin
        ACanvas.Font.Style := Canvas.Font.Style + [fsBold];
      end
      else
      begin
        ACanvas.Font.Style := Canvas.Font.Style - [fsBold];
      end;  Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
        ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter,
        False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
        ACanvas.Font,ACanvas.font.Color,ACanvas.Brush.color );  ADone := True;
    end;
    3.在Indicatoer列头显示"行号"两个字的方法如下
      上述方法实现了indicator中显示行号,但是原来的选中时显示的小箭头因为绘制行号而消失了,所以需要加入以下语句
    procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
      Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    var  //......此处为显示行号的语句  ADone := True;  if AIndicatorViewInfo.GridRecord.Selected then//如果当前为选中行,则显示箭头
      begin
        with cxIndicatorImages, ATextRect do
        begin
          X := Right - Width;
          Y := (Top + Bottom - Height) div 2 ;
        end;
        cxIndicatorImages.Draw(ACanvas.Canvas, X, Y, Ord(ikArrow) - 1);
      end;end;
    4.在indicator列的列头显示“行号”字样的方法
    这个需要修改cxGridTableView单元procedure TcxGridIndicatorHeaderItemPainter.DrawContent;
    begin
      with ViewInfo do
      begin
        LookAndFeelPainter.DrawHeader(Self.Canvas, Bounds, Bounds, [nRight],cxBordersAll,
                     GridCellStateToButtonState(State), taLeftJustify, vaTop, False,
                     False, '', nil, clNone, Params.Color, DrawBackgroundHandler);    if GridView.GetOptionsView.Indicator then //如果为indicator则增加“行号”字样
            LookAndFeelPainter.DrawHeader(Self.Canvas,Bounds,Bounds,[],cxBordersAll, 
                     cxbsNormal, taCenter, vaCenter, 
                     False, False, '行号',
                     Self.Canvas.Font,Self.Canvas.font.Color,Self.Canvas.Brush.color);
        if State = gcsPressed then
           LookAndFeelPainter.DrawHeaderPressed(Self.Canvas, Bounds);
      end;
    end;
    5.修改后的cxgrid样式如下
      

  14.   

    3.在Indicatoer列头显示"行号"两个字的方法如下应修改为3.在Indicatoer列头显示箭头的方法如下