Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: Re: Datagrid ColumnStyles error


Message #1 by "Ana Pereira" <anagpereira@h...> on Thu, 1 Aug 2002 18:06:39
try something like this:



public Sub AddCustomDataTableStyle()
	' adds 2 collumns to datagrid

        datagrid1.SetDataBinding(myDataset,myDataset.Tables(0).TableName)

        Dim ts1 As New DataGridTableStyle()

        ts1.MappingName = myDataset.Tables(0).TableName
        ts1.AlternatingBackColor = Color.LightGoldenrodYellow

        Dim dCol1 As New DataGridTextBoxColumn()
        dCol1.MappingName = "UtilCod" 'name of collumn
        dCol1.HeaderText = "Code"
        dCol1.Width = 150

        ts1.GridColumnStyles.Add(dCol1)

        Dim dCol2 As New DataGridTextBoxColumn()
        dCol2.MappingName = "UtilDsc" 'name of collumn
        dCol2.HeaderText = "Description"
        dCol2.Width = 250

        ts1.GridColumnStyles.Add(dCol2)

     
       
        datagrid1.TableStyles.Add(ts1)
end sub


Ana



> Hello:

I finally assigned the TableStyles to the datagrid. Now when I run the
program, I get the following error:

"The data grid column styles collection already contains a column style 
with
the same mapping name."

If I put dgCustOrders.TableStyles.Clear() first, I don't get this error, 
but
I don't get any styles either.

How to fix this?

I would appreciate any suggestions.

Thank you,

--
Peter Afonin




  Return to Index