[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Brad Shook

12/17/2004 7:44:00 PM

Does anyone know how to create a list box that has lines for every item.
like so:
_______________
|______________|
|______________|
|______________|
|______________|

Thanks,
Brad Shook


1 Answer

Ken Tucker [MVP]

12/18/2004 10:45:00 AM

0

Hi,

You need to draw the listbox yourself. Here is a quick example.


Dim dsXML As New DataSet



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

dsXML.ReadXml("http://msdn.microsoft.com/rss...)

dsXML.WriteXml("rss.xml")



ListBox1.DataSource = dsXML.Tables("item")

ListBox1.DisplayMember = "pubDate"

ListBox1.DrawMode = DrawMode.OwnerDrawFixed



End Sub

Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem

Dim g As Graphics = e.Graphics

Dim dr As DataRowView

Dim dt As Date

Dim br As SolidBrush

Dim s As String

Dim dtCompare As Date = #6/18/2004#

Try

dr = DirectCast(ListBox1.Items.Item(e.Index), DataRowView)

dt = Date.Parse(dr.Item("pubDate").ToString)

s = dt.ToShortDateString

Catch ex As Exception

Trace.WriteLine(ex.ToString)

End Try

g.FillRectangle(Brushes.White, e.Bounds)

If CBool(e.State And DrawItemState.Selected) Then

g.FillRectangle(Brushes.LightBlue, e.Bounds)

End If

If dt < dtCompare Then

br = New SolidBrush(Color.Red)

Else

br = New SolidBrush(Color.Black)

End If

g.DrawString(s, ListBox1.Font, br, _

RectangleF.op_Implicit(e.Bounds))

br.Dispose()

g.DrawRectangle(Pens.Black, e.Bounds)

End Sub



Ken

--------------------------
"Brad Shook" <bshook@echd.org.removeme> wrote in message
news:%23hHyTDH5EHA.3120@TK2MSFTNGP12.phx.gbl...
Does anyone know how to create a list box that has lines for every item.
like so:
_______________
|______________|
|______________|
|______________|
|______________|

Thanks,
Brad Shook