473,396 Members | 1,929 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.

datagrid Header Center

Please como center a datagrid header and the data justify to right?

Thanks a lot
Jun 6 '06 #1
1 1830
Jose,

I use a *HACK* to do it in .NET V1.1

Subclass DataGridColumnStyle and then override its
Alignment and Paint methods

If it's painting a cell you should use the intended aligment.
If it's *not* painting a cell, then it's supposedly painting
the column header, then you should use Center aligment.

<code>
Public Overrides Property Alignment() As
System.Windows.Forms.HorizontalAlignment
Get
If _painting Then
Return MyBase.Alignment ' = intended alignment
Else
'probly painting header?
Return HorizontalAlignment.Center
End If
End Get
Set(ByVal value As System.Windows.Forms.HorizontalAlignment)
MyBase.Alignment = value
End Set
End Property

Protected Overloads Overrides Sub Paint( ... )
_painting = True
MyBase.Paint( ... )
_painting = False
End Sub
</code>

HTH,
Marius.

"Jose" <jo********@unica.com> wrote in message
news:uP**************@TK2MSFTNGP04.phx.gbl...
Please como center a datagrid header and the data justify to right?

Thanks a lot

Jun 7 '06 #2

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

Similar topics

2
by: Jim Dougherty | last post by:
I am using c#.net 2003 and have an an application with a datagrid. The binding is with an array of structs. Everything works ok except the header text is the struct element names and they override...
1
by: VB Programmer | last post by:
I have a datagrid which is bound to a datatable that I create on the fly. How do I set the width of each column via code? Ex: Column 1 is always 100, Column 2 is always 250, etc... Thanks!
2
by: saleek | last post by:
I was wondering if there is a way I can add an extra header to a datagrid? I found this solution on the internet - but it seems quite old and didn't work for me. ...
0
by: Tim::.. | last post by:
Why doesn't my onEditCommand work??? I don't get an error it just doesn't do the page redirect as requested... Thanks ...CODE.. Sub LinkButton_OnClick(ByVal sender As Object, ByVal e As...
4
by: Tim::.. | last post by:
Can someone tell me how I do a response.redirect using a linkbutton in a datagrid! I want to use the record id in a database to send a querystring to an HTML editor so that users are able to...
2
by: John Smith | last post by:
Hi all; Putting "Due" into the column header of a datagrid. Font is a proportional fort. When the alignment is left, there is some space between the column separator bar and the D in Due....
3
by: Simon Abolnar | last post by:
Is it possible to align headers and text in different way. Because with: dgts.GridColumnStyles(0).Alignment = HorizontalAlignment.Center alignment is set for all column (header and text). ...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
1
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.