Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / September 2006

Tip: Looking for answers? Try searching our database.

DataGrid not using TableStyle!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
craig - 26 Sep 2006 14:40 GMT
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
Bart Mermuys - 26 Sep 2006 15:15 GMT
Hi,

>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
[quoted text clipped - 29 lines]
>        End With
>        Me.DataGrid1.CaptionVisible = False

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

> The one that won't work:
>
>        Me.DataGrid2.DataSource = dsBtarget
>        Me.DataGrid2.DataMember = "Btargets"

Here the tablename isn't really case-sensitive.

>        Dim ts2 As New DataGridTableStyle
>        ts2.MappingName = "Btargets"

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

>        With ts2.GridColumnStyles
>            ts2.GridColumnStyles.Add(New DataGridTextBoxColumn)
[quoted text clipped - 12 lines]
> Thanks,
> Craig
craig - 26 Sep 2006 15:33 GMT
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

>Hi,
>
[quoted text clipped - 32 lines]
>> Thanks,
>> Craig

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.