So, I know these are really noob questions, but I have two. One of them is that in the current code I cannot figure out how to adjust the cell with with the text wrap for height and was wondering if someone could lead me in the right direction to do that. The other question is that I don't know why this is only showing the first row. Is there something wrong with the loop?
I'm sure I am making it more difficult then necessary just can't find a premade class for this type of thing that will run on my VS2010. Seems there are only C# classes.
Thanks in advance and here is the code section:
Dim x As Integer = e.MarginBounds.Left
Dim y As Integer = 230
Dim j As Integer = 0
Do While (j < Me.DataGridView1.Columns.Count)
Dim rect As Rectangle = New Rectangle(x, y, 165, Me.DataGridView1.ColumnHeadersHeight)
Dim sf As StringFormat = New StringFormat
sf.LineAlignment = StringAlignment.Center
sf.Alignment = StringAlignment.Center
e.Graphics.FillRectangle(Brushes.LightGray, rect)
e.Graphics.DrawRectangle(Pens.Black, rect)
If (Not (Me.DataGridView1.Columns(j).HeaderText) Is Nothing) Then
e.Graphics.DrawString(Me.DataGridView1.Columns(j).HeaderText, SystemFonts.DefaultFont, Brushes.Black, rect, sf)
End If
x = (x + rect.Width)
j = (j + 1)
Loop
x = e.MarginBounds.Left
y = (y + Me.DataGridView1.ColumnHeadersHeight)
Dim i As Integer = 0
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Do While (i < Me.DataGridView1.Columns.Count)
Dim cell As DataGridViewCell
cell = row.Cells(i)
Dim rect As Rectangle = New Rectangle(x, y, 165, cell.Size.Height)
Dim sf As StringFormat = New StringFormat
sf.LineAlignment = StringAlignment.Center
sf.Alignment = StringAlignment.Center
e.Graphics.DrawRectangle(Pens.Black, rect)
If (Not (cell.Value) Is Nothing) Then
e.Graphics.DrawString(cell.Value.ToString, SystemFonts.DefaultFont, Brushes.Black, rect, sf)
End If
x = (x + rect.Width)
i = (i + 1)
Loop
x = 180
y = (y + row.Height)
Next