从数据库中提取数据时如何显示列表视图的特定值 [英] How to show a particular value for List view while pulling data from DB
本文介绍了从数据库中提取数据时如何显示列表视图的特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有listview从SQL DB加载数据.对于DB中的布尔值,我想显示一个String值.请让我知道该怎么做.检查代码以更好地理解.请帮忙
Hi,
I have listview which loads data from the SQL DB.For a boolean value in the DB i want to show a String value. Please let me know how to do this. Check the code to understand better. Please help
Public Sub PerformLoad()
Try
lvwMain_default.Items.Clear()
Dim mitem As ListViewItem
''Dim frmLgn As New frmLogin
Dim DataSt As New DataSet
Dim sqlSelIss As String = "select IssID, Descrptn,_status,priority,First_name,Last_Name from User_Details where Emp_ID = issDtl.created_by as Name,Created_On from Issue_Details as issDtl where project_id = ''" proId.ToString "''"
DataSt = DataStore.GetDataset(sqlSelIss, sqlConnStr)
For Each row As DataRow In DataSt.Tables(0).Rows
mitem = New ListViewItem
mitem.Text = row.Item("IssID")
mitem.SubItems.Add(row.Item("Descrptn"))
'' status column return a boolean value,
'' i want to show Active for True and Inactive
'' for False
mitem.SubItems.Add(row.Item("Status"))
mitem.SubItems.Add(row.Item("priority"))
mitem.SubItems.Add(row.Item("Name"))
mitem.SubItems.Add(row.Item("Created_On"))
lvwMain_default.Items.Add(mitem)
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
推荐答案
一种快速的方法是:
A quick way would be:
<pre>If row.Item("Status").toString = "True" then<br />
mitem.subItems.Add("Active")<br />
ElseIf row.Item("Status").toString = "False" then<br />
mitem.subItems.Add("Inactive")<br />
End If<pre></pre></pre>
我认为您必须将listview UseItemStyleForSubItems属性设置为false.
检查此 [此 [
I think you have to set the listview UseItemStyleForSubItems property to false.
Check this[^]and this[^].
If my answer solves your problem please mark it as Accepted Answer.
这篇关于从数据库中提取数据时如何显示列表视图的特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文