PC Review


Reply
Thread Tools Rate Thread

Align one Datagrid column

 
 
kieran
Guest
Posts: n/a
 
      19th Aug 2005
Hi,

I have the following datagrid with manually entered rows. I want to
align the values of the second column only - 'more tax' - to the
center, but i can not seem to do this. The first column i want left
aligned - as is. I can align both columns any way together but not one
on its own.

I can not use the property builder of the datagrid as the columns are
not listed in this as the dg columns are created from a datatable.

Anybody any ideas - all help appreciated.

Thanks.

---------------------------------------


dt = New DataTable("Deductions")

dt.Columns.Add("Deduction", GetType(System.String))

dt.Columns.Add("Value", GetType(System.String))

Dim dr As DataRow = dt.NewRow

dr(0) = "TAX"

dr(1) = (split(7))

dt.Rows.Add(dr)

Dim dr1 As DataRow = dt.NewRow

dr1(0) = "More TAX"

dr1(1) = (split(9))

dt.Rows.Add(dr1)



Datagrid1.DataSource = dt

Datagrid1.DataBind()

 
Reply With Quote
 
 
 
 
Phil G.
Guest
Posts: n/a
 
      19th Aug 2005
Hi Kieran,

Sorry it's a rather incomplete answer but there is a class,
DataGridColumnStyle that has an alignment property for text in a column. I'm
sure you can search the net for an example.

HTH.

Regards,

Phil

"kieran" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have the following datagrid with manually entered rows. I want to
> align the values of the second column only - 'more tax' - to the
> center, but i can not seem to do this. The first column i want left
> aligned - as is. I can align both columns any way together but not one
> on its own.
>
> I can not use the property builder of the datagrid as the columns are
> not listed in this as the dg columns are created from a datatable.
>
> Anybody any ideas - all help appreciated.
>
> Thanks.
>
> ---------------------------------------
>
>
> dt = New DataTable("Deductions")
>
> dt.Columns.Add("Deduction", GetType(System.String))
>
> dt.Columns.Add("Value", GetType(System.String))
>
> Dim dr As DataRow = dt.NewRow
>
> dr(0) = "TAX"
>
> dr(1) = (split(7))
>
> dt.Rows.Add(dr)
>
> Dim dr1 As DataRow = dt.NewRow
>
> dr1(0) = "More TAX"
>
> dr1(1) = (split(9))
>
> dt.Rows.Add(dr1)
>
>
>
> Datagrid1.DataSource = dt
>
> Datagrid1.DataBind()
>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      20th Aug 2005
Kieran,

Ken is busy optimizing this sample,

http://www.windowsformsdatagridhelp....5-49bb9074a8bc

Have a look to it, and if you have idea's or questions, let him know usign
the mailbutton you find on this page.

I hope this helps,

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to change horizontal text align for datagrid column Grant_S Microsoft C# .NET 0 5th May 2006 01:17 PM
Right-align Datagrid Column in Web Form David Microsoft ADO .NET 1 17th Mar 2005 02:02 PM
Using Datagrid Problem on Column align Enver Microsoft Dot NET 1 1st Oct 2004 03:42 PM
Using Datagrid Problem on Column align Enver Microsoft Dot NET Framework Forms 1 1st Oct 2004 03:42 PM
Using Datagrid Problem on Column align Enver Microsoft VB .NET 1 1st Oct 2004 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 AM.