Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Why my DatagridStyle is not working

Posted on 2004-04-21
3
238 Views
Last Modified: 2010-04-24
I have given the code below, the datagridstyle which I am assigning to the datagrid is not working

 'Create Table
        Dim dt As New DataTable("DefaultPriceLevel")

        'Add Columns
        Dim dc As DataColumn
        dc = New DataColumn("PriceLevel", System.Type.GetType("System.String"))
        dt.Columns.Add(dc)
        dc = New DataColumn("MarkDownPercent", System.Type.GetType("System.String"))
        dt.Columns.Add(dc)
        dc = New DataColumn("Price", System.Type.GetType("System.String"))
        dt.Columns.Add(dc)

        'Add Rows
        Dim i% : For i = 0 To ds.Tables(3).Rows.Count - 1
            Dim dr As DataRow
            dr = dt.NewRow
            dr("PriceLevel") = ds.Tables(3).Rows(i)(0)
            dr("MarkDownPercent") = ds.Tables(3).Rows(i)(1)
            dr("Price") = ds.Tables(3).Rows(i)(2)
            dt.Rows.Add(dr)
        Next

        'Create Table Style
        Dim ts As New DataGridTableStyle()
        With ts
            .RowHeadersVisible = False
            .BackColor = Color.White
            .AlternatingBackColor = Color.White
            .HeaderBackColor = Color.LightSteelBlue
            .AllowSorting = False
            .HeaderBackColor = Color.FromArgb(115, 126, 183)
            .HeaderForeColor = Color.White
            .HeaderFont = New System.Drawing.Font("Arial", 9.0F, System.Drawing.FontStyle.Bold)
            .GridLineColor = Color.DarkGray
            .PreferredRowHeight = 22
        End With

        'Create Required Column Style (Department)
        Dim column1 As New DataGridTextBoxColumn()
        With column1
            .MappingName = "PriceLevel"
            .Width = 250
            .Alignment = HorizontalAlignment.Left
            .ReadOnly = False
        End With

        'Create Required Column Style (Active)
        Dim column2 As New DataGridTextBoxColumn()
        With column2
            .MappingName = "MarkDown"
            .Width = 100
            .Alignment = HorizontalAlignment.Center
            .ReadOnly = False
        End With

        'Create Required Column Style (Active)
        Dim column3 As New DataGridTextBoxColumn()
        With column3
            .MappingName = "Price"
            .Width = 100
            .Alignment = HorizontalAlignment.Center
            .ReadOnly = False
        End With

        'Add column styles to table style
        ts.GridColumnStyles.Add(column1)
        ts.GridColumnStyles.Add(column2)
        ts.GridColumnStyles.Add(column3)

        'Add tablestyle to Datagrid and customize
        With dgDefaultPriceLevel
            .TableStyles.Add(ts)
            .DataSource = dt
            .CaptionVisible = False
        End With


Any Help is highly appreciated

Regards,

Muthu Annamalai
0
Comment
Question by:MuthuAnnamalai
3 Comments
 

Accepted Solution

by:
fatihdurgut earned 50 total points
ID: 10888768
hi MuthuAnnamalai
it seems that you forgot to assign mappingname of  table style
ts.MappingName = "DefaultPriceLevel"
try this

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question