Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Column Style help!

Status
Not open for further replies.

TimBiesiek

Programmer
Nov 3, 2004
151
AU
Hi all,

I have a datagrid that I'm trying to set out column styles for...

I've got 2 other datagrids in my project, on different forms, that work with no worries! I copied and pasted, then modified the code slightly to fit for the data returned for this grid, but it doesn't seem to change anything!

Help please! Code used is below.

Code:
    Private Sub Frm_RoundAllocPopUp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim RoundPopUpGS As DataGridTableStyle

        Try
            RoundPopUpGS = GridStyle()
            DG_SimilarRounds.TableStyles.Add(RoundPopUpGS)
            Me.DG_SimilarRounds.SetDataBinding(Frm_RoundAllocation.DT_RoundSelect, "")

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

    Public Function GridStyle() As DataGridTableStyle

        Dim myGridStyle As DataGridTableStyle = New DataGridTableStyle
        Dim IDCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim PropIDCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim FlatNumCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim StreetNumCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim StreetCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim SuburbCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim CityCS As DataGridTextBoxColumn = New DataGridTextBoxColumn
        Dim ClientRoundCS As DataGridTextBoxColumn = New DataGridTextBoxColumn

        Try
            myGridStyle.MappingName = "RoundAllocPopUp"

            IDCS.MappingName = "Prop_ID"
            IDCS.HeaderText = "Prop ID"
            IDCS.Width = 0
            IDCS.ReadOnly = True
            myGridStyle.GridColumnStyles.Add(IDCS)

            PropIDCS.MappingName = "Prop_Identifier"
            PropIDCS.HeaderText = "Property Identifier"
            PropIDCS.Width = 120
            PropIDCS.ReadOnly = True
            myGridStyle.GridColumnStyles.Add(PropIDCS)

            FlatNumCS.MappingName = "Street_Add_1"
            FlatNumCS.HeaderText = "Flat Num"
            FlatNumCS.Width = 60
            FlatNumCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(FlatNumCS)

            StreetNumCS.MappingName = "Street_Add_2"
            StreetNumCS.HeaderText = "Street Num"
            StreetNumCS.Width = 70
            StreetNumCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(StreetNumCS)

            StreetCS.MappingName = "Street_Add_3"
            StreetCS.HeaderText = "Street Name"
            StreetCS.Width = 155
            StreetCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(StreetCS)

            SuburbCS.MappingName = "Street_Add_4"
            SuburbCS.HeaderText = "Suburb"
            SuburbCS.Width = 130
            SuburbCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(SuburbCS)

            CityCS.MappingName = "Street_Add_5"
            CityCS.HeaderText = "City"
            CityCS.Width = 140
            CityCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(CityCS)

            ClientRoundCS.MappingName = "Client_Round"
            ClientRoundCS.HeaderText = "Round"
            ClientRoundCS.Width = 100
            ClientRoundCS.ReadOnly = False
            myGridStyle.GridColumnStyles.Add(ClientRoundCS)

            myGridStyle.RowHeadersVisible = True
            myGridStyle.AllowSorting = False
            myGridStyle.HeaderBackColor = System.Drawing.Color.FromArgb(227, 217, 155)
            myGridStyle.AlternatingBackColor = System.Drawing.Color.FromArgb(241, 236, 205)

            Return (myGridStyle)

            myGridStyle.Dispose()
            PropIDCS.Dispose()
            FlatNumCS.Dispose()
            StreetNumCS.Dispose()
            StreetCS.Dispose()
            SuburbCS.Dispose()
            ClientRoundCS.Dispose()
            CityCS.Dispose()

        Catch ex As Exception
            MsgBox(ex.ToString)
            myGridStyle.Dispose()
            PropIDCS.Dispose()
            FlatNumCS.Dispose()
            StreetNumCS.Dispose()
            StreetCS.Dispose()
            SuburbCS.Dispose()
            CityCS.Dispose()
            ClientRoundCS.Dispose()
        End Try

    End Function

This is virtually the same as for my other datagrids!

pcguru.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top