center datagrid

V

Vincent Vinet

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?
 
P

Peter Rilling

Put it in a table.

<table width="100%">
<tr>
<td align="center">
<your datagrid here>
</td>
</tr>
</table>
 
C

Curt_C [MVP]

Vincent said:
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?
<p align=center>
<div....>
<span...>

lots of options if the control isnt doing it itself
 
K

Kivak Wolf

I would guess that you are not using a table inside of the DataGrid
right? I would suggest that you put all of the information inside of a
table (much MUCH cleaner) and than center the table in the <table> and
<tr> tags.

<table align="center">
<tr align="center">
<td>
My data
</td>
<td>
More data
</td>
</tr>
</table>

You may only need to center one of the <tr> or <table> tags, so you
might want to play around with that.

Hope that helps. =D
Kivak Wolf
 
K

Kivak Wolf

Can you really say "<table width="100%">"? I didn't know they allowed
percentages. What will it do?
 
V

Vincent Vinet

well unfortunately the contents of the datagrid are based on search results
on a sql server... I cannot enter data manually, although I do have columns
set up in advance, but centering their content does not affect the
datagrid`s placement
 
K

Kivak Wolf

no, don't put the datagrid inside of a table - Put the table inside the
datagrid. Each <tr> and <td> is used to sort out the data inside the
datagrid. Than just center the <table> and <tr> tags.

If you need more help, put your Datagrid here and I will make it for
you.
 
V

Vincent Vinet

well it seems that there was a LEFT:9px hidden in the code... and then the
center would just put the LEFT part in the middle of the page so I tried
putting it in a table again and it worked... thanks for your time anyhow :)
 
V

Vincent Vinet

I found a pesky piece of code hiding in my source... "left: 9px"
took it out then I put the grid in a centered table of the same width...
works now :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top