zoukankan      html  css  js  c++  java
  • C# Winform DataGridview 实现行号倒序

    设计简单测试界面如上

    选择Datagirdview 的Paint事件

        private void dttest_Paint(object sender, PaintEventArgs e)     

        {            

             int rowcount = dttest.RowCount;   

             int showcount = dttest.DisplayedRowCount(true);    

             if (showcount == 0) return;        

            System.Drawing.Rectangle currrct;          

           int startNo = dttest.FirstDisplayedCell.RowIndex;  

           int ColNo = dttest.FirstDisplayedCell.ColumnIndex;    

           string stext = "";    

            int nowy = 0;         

           int hDelta = 0;      

           for (int i = startNo; i < startNo + showcount; i++)

         {

                currrct = (System.Drawing.Rectangle)dttest.GetCellDisplayRectangle(ColNo, i, true);   

                 nowy = currrct.Y + 2;      

                stext = string.Format("{0, 3}", rowcount - i);       

                 if (hDelta == 0)            

                 hDelta = (currrct.Height - dttest.Font.Height) / 2;   

                  if (dttest.Rows[i].Selected == true)            

             e.Graphics.DrawString(stext, dttest.Font, new System.Drawing.SolidBrush(System.Drawing.Color.White), 10, nowy + hDelta);         

            else       

                  e.Graphics.DrawString(stext, dttest.Font, new System.Drawing.SolidBrush(System.Drawing.Color.Black), 10, nowy + hDelta);

                }      

       }

    Result:

    丫头,记得活的漂亮点儿
  • 相关阅读:
    再谈AR中的图像识别算法
    turret
    Unity之MVC 模式
    Unity之Application.runInBackground = true
    快速了解和使用Photon Server
    Unity Standard Assets 简介之 CrossPlatformInput
    Lua的闭包详解(终于搞懂了)
    代码大全、人月神话和你的灯亮着吗三本软件开发设计方面好书
    大数据入门推荐
    迷茫的旅行商:一个无处不在的计算机算法问题
  • 原文地址:https://www.cnblogs.com/Alisa-study/p/5687565.html
Copyright © 2011-2022 走看看