Visual Basic 2005-如何在 DataGridView 控制項的資料列標題上繪製編號:章立民研究室:Xuite日誌
  • 章立民研究室
  • 文章分類
  • 日曆
  • 搜尋文章
  • 關鍵字
  • 我的好友
  • 最愛日誌
  • 最新文章
  • 最新回應
  • 參觀人氣統計
  • 已建立的日誌
  • 日誌使用資源






  • 如何使用RSS
    Powered by Xuite
    2006-09-28 09:03 Visual Basic 2005-如何在 DataGridView 控制項的資料列標題上繪製編號
  • ?
  • Visual Basic 2005
  • 好文轉寄
  • 平均分數:0 顆星    投票人數:0
    我要評分:
    標籤 : 


    圖表1 

    有許多朋友詢問我,如何在DataGridView控制項的資料列標題上繪製出額外的數字編號。欲完成這樣的處理非常簡單,您只需替DataGridViewRow控制項的RowPostPaint事件處理常式撰寫下列程式碼即可: 

    Private Sub dataGridView1_RowPostPaint(ByVal sender As Object, _
      ByVal e As DataGridViewRowPostPaintEventArgs) _
      Handles DataGridView1.RowPostPaint

      Using b As SolidBrush = _
          New SolidBrush(DataGridView1.RowHeadersDefaultCellStyle.ForeColor)

          e.Graphics.DrawString(e.RowIndex.ToString( _
          System.Globalization.CultureInfo.CurrentUICulture), _
                         DataGridView1.DefaultCellStyle.Font, _
                                                           b, _
                                 e.RowBounds.Location.X + 20, _
                                 e.RowBounds.Location.Y + 4)

      End Using
    End
    Sub



    章立民研究室 / Xuite日誌 / 回應(2) / 引用(0) / 好文轉寄
  • 回應