Solved

VB.Net 2005 - DataGrid Header Centering

Posted on 2014-10-20
2
64 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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