树视图条件格式

时间:2012-12-19 11:32:48

标签: asp.net vb.net treeview conditional-formatting

我有一个像这样的数据集填充的树视图

Dim PrSet As New DataSet()
        If lblemail.Text.ToString().Equals("ali.saleem@shakarganj.com.pk") Then
            PrSet = PDataset("select distinct PEND,to_char(BPV_DTE,'DD MON YYYY') BPV_DTE,BPV_DTE BPV_DTE1,COUNT from chq_dir order by 3 desc")
        Else
            PrSet = PDataset("select distinct PEND,to_char(BPV_DTE,'DD MON YYYY') BPV_DTE,BPV_DTE BPV_DTE1,COUNT from chq_dte order by 3 desc")
        End If
        TreeView2.Nodes.Clear()
        For Each dr As DataRow In PrSet.Tables(0).Rows
            Dim tnParent As New TreeNode()
            tnParent.Text = dr("PEND").ToString()
            tnParent.Value = dr("BPV_DTE")
            tnParent.PopulateOnDemand = True
            tnParent.SelectAction = TreeNodeSelectAction.Select
            tnParent.ToolTip = tnParent.Text
            tnParent.Expand()
            TreeView2.Nodes.Add(tnParent)
            If dr("COUNT").ToString() = "0" Then
                TreeView2.Font.Bold= True
            End If
        Next dr

COUNT在某些日期有0。问题是,我正在尝试将COUNT 0 {{1}}的树视图加粗,但它不是工作任何人都可以给我一个明确的想法。

3 个答案:

答案 0 :(得分:1)

我已经解决了我的问题

 If Not dr("COUNT") = 0 Then
 tnParent.Text = "<b>" & dr("PEND").ToString() & "</b>"
 End If

答案 1 :(得分:0)

将样式应用到tnparent,然后在树视图中将节点添加到父节点之前执行此操作,并且从代码中看起来您将字体更改为斜体而非粗体。

答案 2 :(得分:0)

我希望我已经接受了这个问题的意思......

  For Each tn As TreeNode In treeView2.Nodes
     If tn.Text = "0" Then
          Dim index As Integer
          index = tn.Index
          treeView2.Nodes(index).NodeFont = New Font(treeView2.Font, FontStyle.Bold)
     End If
  Next