Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help setting the Width of a table cell.

Status
Not open for further replies.

blondebier

Programmer
Jun 19, 2003
142
GB
Hi,

I'm populating a table dynamically with 3 table cells.

I am having a problem with the length of the table cells.

I've tried tableCell.Width = Unit.Pixel(100) but this doesn't work.

The data in the middle cells is a description and the cells to the right are textboxes. The problem is that when it loads all the data dynamically, the text boxes do not align properly, they are just placed wherever the text from the description stops. Grrrrr! Any idea how I could fix this annoying problem. Ideally i'd like to set the length of the description cell to a fixed length. i.e. 60% of the table.

Thanks in advance.
Francis
 
Francis,

are you meaning that you want to format the cells within a datagrid? if so then what you need to do is to add a tablestyle to the datagrid and then you can set the width of each column.
HTH,
bueller
 
This is the code that creates the table:

Do While Not rsData.EOF
Dim tableRow As New TableRow()
Dim tableCell As New TableCell()
Dim TextBoxForId As New TextBox()
Dim TextBoxForValue As New TextBox()
Dim DescriptionLabel As New Label()

TextBoxForValue.ID = "TextBoxForValue" & i
TextBoxForId.ID = "TextBoxForId" & i

MyTable.Controls.Add(tableRow)
MyTable.BorderStyle = BorderStyle.Double
tableRow.Controls.Add(tableCell)
tableCell.Controls.Add(TextBoxForId)
tableCell.BorderStyle = BorderStyle.Double
tableCell.Controls.Add(DescriptionLabel)

tableCell.Controls.Add(TextBoxForValue)
TextBoxForId.Text = CStr(rsData("ID").Value)
TextBoxForId.ReadOnly = True
DescriptionLabel.Text = CStr(rsData("Description").Value)
TextBoxForValue.Text = CStr(rsData("txtValue").Value)
rowCount.Value = i
i += 1
rsData.MoveNext()
Loop

I need to be able to make the Value textboxes line up after the description labels. The problem is that all the descriptions have different lengths so the Value text boxes appear randomly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top