all groups > dotnet windows forms databinding > september 2006 >
You're in the

dotnet windows forms databinding

group:

DataGrid not using TableStyle!!


DataGrid not using TableStyle!! craig via DotNetMonster.com
9/26/2006 1:40:31 PM
dotnet windows forms databinding:
I know that there is something stupid here, but I am pulling my hair out
trying to find it, Please help!!. I have a Form that, with various Tab Pages,
has 6 DataGrids. 5 of these DataGrids are using the defined table style and
one won't. I can't find anything different between them.

One that is working:

Me.DataGrid1.DataSource = dsBhvPlan
Me.DataGrid1.DataMember = "BhvPlan"

Dim ts1 As New DataGridTableStyle
ts1.MappingName = "BhvPlan"
With ts1.GridColumnStyles
ts1.GridColumnStyles.Add(New DataGridTextBoxColumn)
With .Item(0)
.HeaderText = "Objective Nunber"
.MappingName = "objno"
.Width = 0.2 * Me.DataGrid1.Width
.NullText = String.Empty
End With
ts1.GridColumnStyles.Add(New DataGridTextBoxColumn)
With .Item(1)
.HeaderText = "Title"
.MappingName = "title"
.Width = 0.78 * Me.DataGrid1.Width
.NullText = String.Empty
End With
ts1.GridColumnStyles.Add(New DataGridTextBoxColumn)
DataGrid1.TableStyles.Add(ts1)
End With
Me.DataGrid1.CaptionVisible = False


The one that won't work:

Me.DataGrid2.DataSource = dsBtarget
Me.DataGrid2.DataMember = "Btargets"

Dim ts2 As New DataGridTableStyle
ts2.MappingName = "Btargets"
With ts2.GridColumnStyles
ts2.GridColumnStyles.Add(New DataGridTextBoxColumn)
With .Item(0)
.HeaderText = "Targeted Behavior"
.MappingName = "type"
.Width = 0.28 * Me.DataGrid2.Width
.NullText = String.Empty
End With
ts2.GridColumnStyles.Add(New DataGridTextBoxColumn)
Me.DataGrid2.TableStyles.Add(ts2)
End With


Please let me know of anything that you see, I'm going Crazy!

Thanks,
Craig

--
Message posted via http://www.dotnetmonster.com
Re: DataGrid not using TableStyle!! Bart Mermuys
9/26/2006 2:15:51 PM
Hi,

[quoted text, click to view]

The only reason i can think of why a DataGridTableStyle doesn't work is
because an incorrect MappingName is used.

[quoted text, click to view]

Here the tablename isn't really case-sensitive.

[quoted text, click to view]

Here the tablename *is* case-sensitive.

So i would check the exact tablename, eg. print it out before setting the
MappingName:

Console.WriteLine( dsBtarget.Tables("Btargets").TableName )

HTH,
Greetings


[quoted text, click to view]

Re: DataGrid not using TableStyle!! craig via DotNetMonster.com
9/26/2006 2:33:47 PM
AARrrrrgghhhhh!!

I can't believe it was that simple! You hit it on the head! The table name
was "BTargets" not "Btargets"

Thanks a bunch!
Craig

[quoted text, click to view]

--
Message posted via http://www.dotnetmonster.com
AddThis Social Bookmark Button