Minying's Blog

Just another WordPress.com weblog

Posts Tagged ‘DataGridView’

隨資料移動 DataGridView 的指標

Posted by minying 於 21 四月, 2009

資料載入 DataGridView 後,常會用迴圈的方式進行處理,在處理的過程中,為了不使畫面看起來像當掉一般沒有反應,通常我會用隨資料移動 DataGridView 指標的方法,讓使用者知道目前正處理到那一行資料,當然也可以用 ProgressBar 元件的方式或用文字顯示百分比。 繼續閱讀文章 »

Posted in VB.NET | 已加上的標籤: | Leave a Comment »

顯示 DataGridView 的行號

Posted by minying 於 21 四月, 2009

顯示 DataGridView 的行號,可在 DataGridView 的 RowPostPaint 事件中加入以下程式碼

Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
        Dim rectangle As New Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, DataGridView1.RowHeadersWidth – 4, e.RowBounds.Height)
        TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), DataGridView1.RowHeadersDefaultCellStyle.Font, rectangle, DataGridView1.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter Or TextFormatFlags.Right)
End Sub

Posted in VB.NET | 已加上的標籤: | Leave a Comment »