首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

高分求解:怎么设置datagridview行头与列头交叉处单元格的值

2011-12-31 
高分求解:如何设置datagridview行头与列头交叉处单元格的值如题.....[解决办法]VB.NET codePublic Class F

高分求解:如何设置datagridview行头与列头交叉处单元格的值
如题.....

[解决办法]

VB.NET code
Public Class Form1    Private DataGridView1 As New DataGridView    Private Label1 As New Label    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        AddHandler DataGridView1.CellPainting, AddressOf DataGridView1_CellPainting        Me.DataGridView1.AllowUserToResizeRows = False        Me.DataGridView1.AllowUserToResizeColumns = False        Me.DataGridView1.Dock = DockStyle.Fill        Me.DataGridView1.Columns.Add("Column1", "Column1")        Me.DataGridView1.Columns.Add("Column2", "Column2")        Me.Label1.Visible = False        Me.Label1.Text = "test"        Me.Label1.AutoSize = False        Me.BackColor = Color.BlueViolet        Me.Label1.BorderStyle = BorderStyle.Fixed3D        Me.Label1.TextAlign = ContentAlignment.MiddleCenter        Me.Controls.Add(DataGridView1)        Me.Controls.Add(Label1)    End Sub    Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs)        If e.RowIndex = -1 And e.ColumnIndex = -1 Then            Dim p As Point = Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Location            p.Offset(Me.DataGridView1.Left, Me.DataGridView1.Top)            Me.Label1.Location = p            Dim s As Size = Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False).Size            Me.Label1.Size = s            Me.Label1.Visible = True            Me.Label1.BringToFront()        End If    End SubEnd Class 

热点排行