Hi,
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
For x As Integer = 0 To 20
ListBox1.Items.Add(String.Format("Item {0} {1} Line 2", x,
ControlChars.NewLine))
Next
ListBox1.DrawMode = DrawMode.OwnerDrawVariable
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 s As String
Dim d As Date
Dim br As Brush = SystemBrushes.WindowText
Dim brBack As Brush
Dim rDraw As Rectangle
Dim bSelected As Boolean = CBool(e.State And
DrawItemState.Selected)
rDraw = e.Bounds
rDraw.Inflate(-1, -1)
If bSelected Then
brBack = Brushes.LightBlue
g.FillRectangle(Brushes.LightBlue, rDraw)
g.DrawRectangle(Pens.Blue, rDraw)
Else
brBack = Brushes.White
g.FillRectangle(brBack, e.Bounds)
End If
br = Nothing
brBack = Nothing
rDraw = Nothing
Try
s = ListBox1.Items.Item(e.Index).ToString
Catch
s = ""
End Try
Debug.WriteLine(String.Format("{0} {1} {2}", e.Index, s,
e.Bounds.ToString))
g.DrawString(s, ListBox1.Font, Brushes.Black,
RectangleF.op_Implicit(e.Bounds))
End Sub
Private Sub ListBox1_MeasureItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.MeasureItemEventArgs) Handles ListBox1.MeasureItem
e.ItemHeight += e.ItemHeight
End Sub
Ken
-------------
"Max" <ma*****@yahoo.com> wrote in message
news:Ne********************@comcast.com:
I need some control that basically acts as a listbox, but allows each
item to take up more then one line. I've tried adding a new item and
putting in a vbCrLf in there, but that just comes out as a box on the
same line. Is there some way of making the listbox show multiple lines
for each item, or is there another control (3rd party maybe) that will
let me do this?
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (
http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 262.10.6 - Release Date: 5/28/2004