2012-08-22 66 views
0

我想畫一張2列的表格。第一列將有2行,每行分別包含a和b字母,第二列不包含行。這裏是我的代碼.....如果有人能幫助我儘快將在第二的第一個單元格感激vb.net中的表格繪圖

Public Class trialtable 
    Inherits System.Web.UI.Page 

    Protected Sub trialtable(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
     Dim trial As DataTable 
     trial = New DataTable 
     Dim tbl As New Table() 

     Dim szName As String = "" 
     Dim szNumber As String = "" 
     Dim szsadasd As String = "" 
     tbl.BorderColor = Drawing.Color.Black 
     tbl.BorderWidth = 1 
     tbl.CellPadding = 0 
     tbl.CellSpacing = 0 

     For i As Integer = 0 To 1 
      Dim tr As New TableRow() 
      Dim tc1 As New TableCell() 
      Dim tc2 As New TableCell() 
      Dim tc3 As New TableCell() 
      tc1.Controls.Add(New LiteralControl(szName)) 
      tc2.Controls.Add(New LiteralControl(szNumber)) 
      tc3.Controls.Add(New LiteralControl(szsadasd)) 
      tc1.BorderColor = Drawing.Color.Black 
      tc1.BorderWidth = 1 
      tc2.BorderColor = Drawing.Color.Black 
      tc2.BorderWidth = 1 
      tc3.BorderColor = Drawing.Color.Black 
      tc3.BorderWidth = 1 
      tr.Cells.Add(tc1) 
      tr.Cells.Add(tc2) 
      tr.Cells.Add(tc3) 
      tbl.Controls.Add(tr) 
     Next 
     Me.Controls.Add(tbl) 
    End Sub 
End Class 
+0

聽起來像功課,我...如果是這樣的話,p租賃標籤這樣的問題 – freefaller

+0

它不是一個家庭作業它在我的辦公室任務,但案件是我從來沒有使用表我總是使用gridviews – charbel

+0

什麼是阻止你直接在HTML標記中創建表? – freefaller

回答

0

爲了將價值a在第一行的第一個單元格,b行,什麼都沒有了兩行中的第二小區,替換下面的代碼行...

tc1.Controls.Add(New LiteralControl(szName)) 
tc2.Controls.Add(New LiteralControl(szNumber)) 

用下面的代碼...

If i = 0 Then 
    tc1.Controls.Add(New LiteralControl("a")) 
Else 
    tc1.Controls.Add(New LiteralControl("b")) 
End If 
tc2.Controls.Add(New LiteralControl(" ")) 
+0

好男人,謝謝它的工作非常感謝你 – charbel