473,325 Members | 2,671 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,325 software developers and data experts.

DataGrid - centering

I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolColumn,
the checkbox is displayed in the center of the cell, horizontally and
vertically aligned.

I want the other cells with data to also be centered so that it is
congruent with the checkbox. I'm having problems centering the data
vertically.

The data always is aligned to the top of the cell, and I want it to be
in the center of the cell.

I've looked at many websites, and this isn't mentioned. Is it
impossible to do this?

Any help?

Thanks very mucn.
Nov 16 '05 #1
2 2134
Hi,

You will most likely need to provide your own painting and control hosting
logic to achieve that.
To provide your own painting, override the Paint method in the
DataGridColumnStyles.
Providing your own control hosting layout is a more complex task, if you
have source code for custom column styles such as numeric up-down, this
should help you a lot.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"anonymous" <si*******@hotmail.com> wrote in message
news:41**************************@posting.google.c om...
I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolColumn,
the checkbox is displayed in the center of the cell, horizontally and
vertically aligned.

I want the other cells with data to also be centered so that it is
congruent with the checkbox. I'm having problems centering the data
vertically.

The data always is aligned to the top of the cell, and I want it to be
in the center of the cell.

I've looked at many websites, and this isn't mentioned. Is it
impossible to do this?

Any help?

Thanks very mucn.


Nov 16 '05 #2
Thanks a lot. That was very helpful and gives me some idea how to
approach this problem. I have never overrided the Paint method
before. Does this mean that I have to implement everything or just
override the parts I need to change? I supposed when I research into
this more, it will become more clear. If you happen to know any good
websites/samples, that would be great. Otherwise, don't worry about
it. I'll look it up.

What do you mean by providing my own control hosting layout. Do you
mean that when the cell is clicked, the appropriate control is shown
so that the DataGrid hosts the needed controls?

Thanks again.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<ek*************@TK2MSFTNGP12.phx.gbl>...
Hi,

You will most likely need to provide your own painting and control hosting
logic to achieve that.
To provide your own painting, override the Paint method in the
DataGridColumnStyles.
Providing your own control hosting layout is a more complex task, if you
have source code for custom column styles such as numeric up-down, this
should help you a lot.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"anonymous" <si*******@hotmail.com> wrote in message
news:41**************************@posting.google.c om...
I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolColumn,
the checkbox is displayed in the center of the cell, horizontally and
vertically aligned.

I want the other cells with data to also be centered so that it is
congruent with the checkbox. I'm having problems centering the data
vertically.

The data always is aligned to the top of the cell, and I want it to be
in the center of the cell.

I've looked at many websites, and this isn't mentioned. Is it
impossible to do this?

Any help?

Thanks very mucn.

Nov 16 '05 #3

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

Similar topics

11
by: Jeff Thies | last post by:
I have a series of blocks that are float left that I need centered on the page. <div class="center" align="center"> <div style="width: 100 px;float: left">thumbnail 1</div> <div style="width:...
15
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side...
6
by: Axel Siebenwirth | last post by:
Hi, as described at http://www.quirksmode.org/css/centering.html, I try to do to centering with my site. I did exactly as told on that page but it only seems to center horizontally. My site...
1
by: john sutor | last post by:
Does anyone know of a way to center the column headings on the DataGrid without centering the data in the columns?
16
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">...
12
by: Vincent Vinet | last post by:
I am trying to center a datagrid horizontally on a form, yet it stays aligned right... the horizontal align property seems to be useless, just as putting the grid inside a centered div or table...
3
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a...
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
1
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.