473,547 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid - centering

I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolCol umn,
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 2150
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
DataGridColumnS tyles.
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*******@hotm ail.com> wrote in message
news:41******** *************** ***@posting.goo gle.com...
I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolCol umn,
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.c om> wrote in message news:<ek******* ******@TK2MSFTN GP12.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
DataGridColumnS tyles.
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*******@hotm ail.com> wrote in message
news:41******** *************** ***@posting.goo gle.com...
I have created a DataGrid control with checkboxes, TextBoxes,
ComboBoxes, and NumericUpDowns. Since I used the DataGridBoolCol umn,
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
15031
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: 100 px;float: left">thumbnail 2</div> <div style="width: 100 px;float: left">thumbnail 3</div> </div>
15
13481
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 with float. But I can't center two side by side divs. If I float them and give them auto margins, the auto margins are ignored. If I wrap the...
6
2028
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 is at http://www.up-2-d8.de/menu.html Can you please take a look and see whether you can find anything I am doing wrong?!
1
294
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
1668
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"> <FooterTemplate> <asp:LinkButton CommandName="Insert" Text="<img src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
12
1942
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 is there any other way to center the grid?
3
4191
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 top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window?...
5
4809
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 doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
1
2274
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 rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. ...
0
7510
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7437
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7703
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7797
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1050
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
748
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.