VB コードで、if ステートメント中にテキストを赤色に変更する Div を作成する前に、テキストがチェックボックスの横に配置されていました。色変更のコードを追加するとchild.Text = "<div style='color:Red; display: inline; float: left;'>" + child.Text & "</div>"
、チェックボックスの横ではなくチェックボックスの下にテキストが移動します。Span を試しましたが、うまくいきません。チェックボックスの横にテキストを表示したい。
ここに詳細な VB コードがあります。
'populate the child nodes
While dr.Read()
Dim child As TreeNode = New TreeNode(dr("Name"), dr("Name"))
Dim complianceFlag As Boolean
If Boolean.TryParse(dr("Compliance"), complianceFlag) Then
' Yes, compliance value is a Boolean, now set color based on value
If Not complianceFlag Then
child.Text = "<div style='color:Red; display: inline; float: left;'>" + child.Text & "</div>"
End If
Else
End If
rootNode.ChildNodes.Add(child)
child.SelectAction = TreeNodeSelectAction.None
End While
HTMLコード、
<div>
<asp:UpdatePanel ID="UpdatePanel6" runat="server">
<ContentTemplate>
<asp:TreeView onclick="client_OnTreeNodeChecked();" ID="TreeViewGroups" runat="server"
ShowCheckBoxes="All" ExpandDepth="0" CssClass="bold">
</asp:TreeView>
<asp:Label ID="LabelNoServers" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<%--<asp:AsyncPostBackTrigger ControlID="b_DelYes" EventName="Click" />--%>
</Triggers>
</asp:UpdatePanel>
</div>