TableCell Widths

T

Tom

I'm dynamically creating a table with the 1st cell having a checkbox control
which is created and added to the cell...the next 3 cells contain textboxes.

I can set the width of the 1st cell width and that works (width changes) but
when I set the width of the cells that contain textboxes the width settings
seemed to be ignored. I'm setting the width of the textboxes and that is
working but it seems like the width of the cells are assuming the default
width of the textboxes. If I don't set the width of the textboxes the cells
and textboxes are the same width. When setting the width of the textbox the
cell width is the same.
Thanks...Tom

textBoxTax = new TextBox();


textBoxTax.Width = TAX_AMOUNT_WIDTH;

tableCell = new TableCell();

tableCell.BorderStyle = BorderStyle.Solid;

tableCell.HorizontalAlign = HorizontalAlign.Right;

tableCell.VerticalAlign = VerticalAlign.Top;

tableRow.Cells.Add(tableCell);

tableCell.Controls.Add(textBoxTax);
 
S

S. Justin Gengo

Tom,

I'd try two things:

First try setting the cell width via its style setting:
tableCell.Style.Add(HtmlTextWriterStyle.Width, TAX_AMOUNT_WIDTH)
Also, I think you may have to set the cell a few pixels wider than the text
box. Try 2 pixels larger.

Second try adding your textbox to the cell before you add the cell to the
row. I've seen small differences crop up when adding objects to cells after
the cell is added to the row (although I doubt this one will make a
difference).

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

S. Justin Gengo

Tom,

Looking at the screenshot you sent I have something different to try. It
looks as if you have the overall table set to a width of 100%. Try changing
that and specifically setting the width on every column to a small pixel
specific value as an experiment.

When you set a table to a width of 100% .NET many times expands all table
cells to take up parts of the overall width. By specifying specific values
for each and every column width you should be able to control which cells
are able to expand and which aren't.

After you experiment with the widths to see if this works try setting the
table to 100%, the very last column to a percentage width of say 75%, and
all other columns to a fixed width of something like 100px. You should then
be able to begin experimenting with various combinations of percent and
fixed widths until you get the results you want.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top