Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > TableCell Widths

Reply
Thread Tools

TableCell Widths

 
 
Tom
Guest
Posts: n/a
 
      12-12-2008
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);


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-12-2008
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




"Tom" <(E-Mail Removed)> wrote in message
news:OyABHd$(E-Mail Removed)...
> 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);
>
>


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-12-2008
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




"Tom" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks S.
>
> I tried your suggestions and still can't change the width of the cells w/
> textboxes. I attached a screenshot in case it could help.
>
> "S. Justin Gengo"
> <justin[remove-to-mail]@about-delete-to-mail-fortunate.com> wrote in
> message news:(E-Mail Removed)...
>> 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
>>
>>
>>
>>
>> "Tom" <(E-Mail Removed)> wrote in message
>> news:OyABHd$(E-Mail Removed)...
>>> 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);
>>>
>>>

>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TableCell oTableCell = new TableCell(); noWrap? Brian K. Williams ASP .Net 2 04-30-2004 12:04 AM
capture a tablecell event Mr. x ASP .Net 0 09-01-2003 11:32 PM
Inserting text into TableCell at runtime Jurjen de Groot ASP .Net 3 08-18-2003 09:38 PM
convert tablecell to boundcolumn May ASP .Net 0 06-30-2003 07:43 PM
TableCell Serdar Kalaycę ASP .Net 4 06-30-2003 03:50 PM



Advertisments