Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2010, 04:27 PM
Authorized User
 
Join Date: Feb 2010
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default (RESOLVED) Format DataGridView Columns using script

Hi Guys,

I am was from VbNet2003 and new to VbNet2008. I am having problem trying to write script to format DataGridView columns like the way I did on VbNet2003.

Here is the sample of script that I used in VB.NET 2003. Does VB.NET 2008 works the same way ?

Code:
Private Function FFormatCustomerDataGridColumn()
    'format DataGrid Column
    Dim dgStyle As New DataGridTableStyle
    dgStyle.MappingName = "ordTbl"

    '----------------------------------------------
    'customerID
    Dim CustIDCol As New DataGridTextBoxColumn
    With CustIDCol
	.MappingName = "CustomerID"
	.HeaderText = "Customer ID"
	.Alignment = HorizontalAlignment.Center
	.Width = 100
	dgStyle.GridColumnStyles.Add(CustIDCol)
     End With

    '-------------------------------------------------
    ' Customer Name
     Dim CustNameCol As New DataGridTextBoxColumn
     With CustNameCol
	.MappingName = "CompanyName"
 	.HeaderText = "Customer Name"
	.Alignment = HorizontalAlignment.Left
	.Width = 250
	dgStyle.GridColumnStyles.Add(CustNameCol)
     End With

    ' ----------------------------------------------------
    'Add Table Style to datagrid -clear before formatting
	DataGrid1.TableStyles.Clear()
	dgStyle.ForeColor = Color.Black
	DataGrid1.TableStyles.Add(dgStyle)
	DataGrid1.ReadOnly = True
	DataGrid1.CaptionText = "Customer Listing Click on Line Item to    display Order Listing"

End Function
Please help me, I need your help.
Thank You
__________________


Thank you very much.

Have a good day.

Cheers,
Lennie

Last edited by Lennie; March 21st, 2010 at 07:05 AM.. Reason: RESOLVED





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
DataGridView Auto Format? MLyons10 C# 2005 0 December 5th, 2006 10:26 AM
datagridview currency format rounds off cents TomH VB Databases Basics 2 September 12th, 2006 11:24 AM
Format checkbox for datagridview in code datawiz1 Visual Basic 2005 Basics 0 June 30th, 2006 03:22 PM
vb script + excel - select multiple columns mohit Excel VBA 1 January 21st, 2005 06:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.