| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1883 人关注过本帖
标题:DataGridView控件中如何自动产生行号
只看楼主 加入收藏
xyxcc177
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:26
帖 子:197
专家分:1249
注 册:2017-7-8
结帖率:100%
收藏
 问题点数:0 回复次数:0 
DataGridView控件中如何自动产生行号
程序代码:
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1

Private Sub DataGridView1_RowPostPaint(sender As Object, e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
        Dim mFont As New System.Drawing.Font("Cambria", 9, FontStyle.Italic) '设置字体字号
        Dim rowIdx As Long = (e.RowIndex + 1).ToString()
        Dim centerFormat As New StringFormat()
        Dim Alignment = StringAlignment.Center
        Dim LineAlignment = StringAlignment.Center
        Dim headerBounds As New Rectangle(e.RowBounds.Left + 10, e.RowBounds.Top + 5, DataGridView1.RowHeadersWidth, e.RowBounds.Height)
        e.Graphics.DrawString(rowIdx, mFont, SystemBrushes.ControlText, headerBounds, centerFormat)

    End Sub
End Class


[此贴子已经被作者于2017-11-16 08:03编辑过]

搜索更多相关主题的帖子: 控件 自动 System Dim New 
2017-11-11 08:49
快速回复:DataGridView控件中如何自动产生行号
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016428 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved