CSS 3を使用しているのはうれしいことですが、現時点ではこれは実用的ではなく、標準がまだ使用されていないことを認識しています。したがって、私の問題を解決するために、コードの背後にあるコンテンツのサイズを測定し、列に壊れているかどうかを示すフラグをテーブルに追加しました。これは、Divタグまたはテーブルセルのいずれかで使用できます。 Divタグを使用した後、私は表のプロパティに一貫性があり、電子メールメッセージでの表示方法も変わったため、表のセルに切り替えました。あなたのaspxページの代わりに コンテンツがでレンダリングされるべき最初のセルまたはのdivタグの内側リピータまたはリストコントロール:あなたが4つのもの、 あなたの含有量を測定する機能を必要とするの後ろにあなたのコードでは
<table cellpadding="2" cellspacing="0">
<tr valign="top" >
<td runat="server" id="TopTD">
<asp:ListView ID="List" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<asp:literal runat="server" id="divdivide"
visible='<%# eval("BreakFields") %>' Text='<%# eval("DivTag")%>'></asp:literal>
<%# eval("Content")%>
</ItemTemplate>
<ItemSeparatorTemplate>
</asp:ListView>
</td>
</tr>
</table>
</div>
あなたの列のサイズ
測定機能を表示する列数を持つプロパティで プロパティをあなたのコンテンツを詰め込むにテーブル:
Function stringSize(ByVal strTarget As String, ByVal strFont As String, ByVal sngFontSize As Single) As SizeF
strFont = "Arial, Sans-Serif"
Dim bitImg As New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(bitImg)
Dim f As New Font(strFont, sngFontSize)
Dim size As SizeF
g.PageUnit = GraphicsUnit.Pixel
size = g.MeasureString(strTarget, f)
Dim I As Int32
If Not String.IsNullOrEmpty(strTarget) Then
Dim Re As New Regex(vbCrLf)
I = Re.Matches(strTarget).Count
End If
If ColumnWidth > 0 Then
size.Height = (size.Height * (Math.Ceiling(size.Width/ColumnWidth))) + (I * 20)
size.Width = ColumnWidth
Else
size.Height = (size.Height * (Math.Ceiling(size.Width/DefaultSize))) + (I * 20)
size.Width = DefaultSize
End If
g.Dispose()
bitImg.Dispose()
f.Dispose()
Return size
End Function
Public ColumnWidth() As Int32
データを表示するときは、テーブルに入れて測定する必要があります。
Dim DT As New DataTable
DT.Columns.Add("Content", GetType(Int32))
DT.Columns.Add("Height", GetType(Int32))
DT.Columns.Add("BreakFields", GetType(Boolean))
Dim Row As DataRow
For Each itemtodisplay
Row = DT.NewRow
Row("Content") = itemtodidisplay
Row("Height") = 0
Row("Height") += Fix(stringSize(itemtodisplay, "Arial", 10).Height)
Row("Height") += 10
HeightCounter += Row("Height")
DT.Rows.Add(Row)
Next
BindItems(DT, Top, StartDate)
使用、これは実際には、リストコントロール
Private Sub BindItems(ByVal DT As DataTable)
If ColumnCount <= 0 Then
ColumnCount = 1
End If
Dim I As Int32
Dim HeightBreak As Int32 = (HeightCounter/ColumnCount) + 40
Dim CurrentCol As Int32 = 1
Dim Curheight As Int32
I = 0
Dim width As Int32
If ColumnWidth > 0 Then
width = ColumnWidth
else
width = DefaultSize
End If
If ColumnWidth > 0 Then
TopTD.Width = width + 6
DT.Columns.Add("DivTag", GetType(String))
DT.Columns.Add("DivStyle", GetType(String))
For Each Row In DT.Rows
Row("DivStyle") = "width:" & width & "px; text-align:left;padding-bottom:3px;"
If (Row("Height") + Curheight) > HeightBreak + 50 _
And I > 0 _
And ColumnCount > 1 _
And CurrentCol < ColumnCount Then
Row("BreakFields") = True
Row("DivTag") = "</td><td width=" & width + 6 & ">"
CurrentCol += 1
Curheight = 0
Else
Row("BreakFields") = False
End If
I += 1
Curheight += Row("Height")
Next
StoryList.DataSource = DT
StoryList.DataBind()
End Sub
に結合するテーブルを作成するには、「左から右スタック」とはどういう意味ですか?列について話していますか? – Shog9