Solved

VB.Net 2005 - DataGrid Header Centering

Posted on 2014-10-20
2
61 Views
Last Modified: 2015-02-13
Good Day Experts!

I am having a bit of trouble trying to get my column headings in the DataGrid to be centered in the header cell.  The columns are getting generated at runtime.  

I am using the following code to try an add the centering:

                        Dim dgvColumnHeaderStyle As New DataGridViewCellStyle()
                        dgvColumnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                        dgrdLineItem.ColumnHeadersDefaultCellStyle = dgvColumnHeaderStyle
                        dgrdLineItem.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
                        dgrdLineItem.AutoGenerateColumns = True
                        dgrdLineItem.DataSource = tblLineItemsFinal

Does that look good to you? What am I missing?

Thanks for your advice,
jimbo99999
0
Comment
Question by:Jimbo99999
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
ID: 40394161
TRY TO SET THIS   dgrdLineItem.AutoGenerateColumns = FALSE
0
 

Author Comment

by:Jimbo99999
ID: 40400464
Hey There:

I apologize, but I need to generate them as I do not have them defined in the DataGrid.

Thanks,
jimbo99999
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now