Hi Steve,
Thanks for your post!
Yes, DataGridView.RowTemplate property is used for the default row
template
of new created rows. So if you change the DataGridView.RowTemplate
property
before the DataGridView is bound, DataGridView will use this modified
value
to display the rows. However, if you change this property after the all
the
rows are created, its modification will not reflect on existing rows. If
you add a new row into the DataGridView, the new row will reflect this new
DataGridView.RowTemplate value.
Below is the sample code demonstrates my statement:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.DataGridView1.RowTemplate.Height =
Me.DataGridView1.RowTemplate.Height + 10
Dim dr As DataRow
dr = dt.NewRow()
dr("column1") = 100
dr("column2") = "item100"
dt.Rows.Add(dr)
End Sub
Dim dt As New DataTable
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dt.Columns.Add("column1", GetType(Integer))
dt.Columns.Add("column2", GetType(String))
Dim i As Integer
Dim dr As DataRow
For i = 0 To 5
dr = dt.NewRow()
dr("column1") = i
dr("column2") = "item" + i.ToString()
dt.Rows.Add(dr)
Next
Me.DataGridView1.DataSource = dt
End Sub
End Class
If you click the Button1, the new added row will be 10 pixel heigher than
original rows.
To change the existing rows height, you should enumerate through the
DataGridView.Rows collection to get each DataGridViewRow reference and
change its Height property. The code snippet below demonstrate this:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim i As Integer
Dim dgvr As DataGridViewRow
For i = 0 To Me.DataGridView1.Rows.Count - 1
dgvr = Me.DataGridView1.Rows(i)
dgvr.Height = dgvr.Height + 10
Next
End Sub
Hope this helps!
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.