473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Align one Datagrid column

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()

Nov 21 '05 #1
2 2306
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" <ki********@hotmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...
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()

Nov 21 '05 #2
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
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Enver | last post by:
Hi! I am trying to use a datagrid control on a smart device application. I managed to see my data on it but i have to arrange the width of columns. How can i do that? I ve tried to use...
2
by: Bill Gates | last post by:
Hi All, I am having a little trouble aligning information in my Datagrid, what I want to do is align the Header text of a column to the left but the detail information of this column to the...
1
by: Arne | last post by:
How do I right align a column in a datagrid?
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
3
by: Li Pang | last post by:
I want to align column title "CENTER" but to align the data "RIGHT". Is anyone knows that Thanks in advance
0
by: Grant_S | last post by:
Can anyone help with a code snippet to right align a single column in the standard Visual studio 2003 datagrid? I need to do this alignment manipulation in code and therefore not able to set...
2
by: Jacksm | last post by:
How can I align an asp:table columns with gridview columns (the widths)? I have tried setting table.column(0).width = gridview.column(0).width at page_load but it doesn't work. Thanks in advance
3
by: remya1000 | last post by:
I’m using Vb.net application program. I created a datagrid having text field and checkbox fields. Everything is displaying correctly. I have 9 Columns and each columns are equally separated. In...
4
by: Skakac | last post by:
Hi! Is it possible to align values in cell in DataGrid control? Thnx.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.