Try this. Without adding the DataGridColumnColumnStyle ( Which must be
Inherited ) you have no styles to reference. Look up the documentation for
more information.
HTH
Class MyColumnStyle
Inherits DataGridColumnStyle
Protected Overrides Sub Abort(ByVal rowNum As Integer)
End Sub
Protected Overrides Function Commit(ByVal dataSource As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean
End Function
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
bounds
As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal
instantText
As String, ByVal cellIsVisible As Boolean)
End Sub
Protected Overrides Function GetMinimumHeight() As Integer
End Function
Protected Overrides Function GetPreferredHeight(ByVal g As
System.Drawing.Graphics, ByVal value As Object) As Integer
End Function
Protected Overrides Function GetPreferredSize(ByVal g As
System.Drawing.Graphics, ByVal value As Object) As System.Drawing.Size
End Function
Protected Overloads Overrides Sub Paint(ByVal g As
System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal
source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As
System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal
source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer,
ByVal alignToRight As Boolean)
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Style2 As New DataGridTableStyle
Try
Style2.GridColumnStyles.Add(New MyColumnStyle)
Style2.GridColumnStyles.Add(New MyColumnStyle)
DataGrid2.TableStyles.Add(Style2)
DataGrid2.TableStyles(0).GridColumnStyles.Item(0).Width = 120
DataGrid2.TableStyles(0).GridColumnStyles.Item(1).Width = 400
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
Dave Edwards said:
Thanks for this, I see what your saying but I think i'm being
particularly
thick today as I can't work out what i should be doing with the code you
supplied,
thanks again
Dave
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message