I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Thanks,
Shane 8 3040
On Thu, 8 Jul 2004 22:25:49 -0500, "SStory"
<Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote: I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Thanks,
Shane
Can you post the code from your DrawItem sub please.
Hi,
Dim dsXML As New DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
dsXML.ReadXml(" http://msdn.microsoft. com/rss.xml")
dsXML.WriteXml( "rss.xml")
ListBox1.DataSo urce = dsXML.Tables("i tem")
ListBox1.Displa yMember = "pubDate"
ListBox1.DrawMo de = DrawMode.OwnerD rawFixed
End Sub
Private Sub ListBox1_DrawIt em(ByVal sender As Object, ByVal e As
System.Windows. Forms.DrawItemE ventArgs) Handles ListBox1.DrawIt em
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(List Box1.Items.Item (e.Index), DataRowView)
dt = Date.Parse(dr.I tem("pubDate"). ToString)
s = dt.ToShortDateS tring
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
g.FillRectangle (Brushes.White, e.Bounds)
If CBool(e.State And DrawItemState.S elected) Then
g.FillRectangle (Brushes.LightB lue, e.Bounds)
End If
If dt < dtCompare Then
br = New SolidBrush(Colo r.Red)
Else
br = New SolidBrush(Colo r.Black)
End If
g.DrawString(s, ListBox1.Font, br, _
RectangleF.op_I mplicit(e.Bound s))
br.Dispose()
End Sub
Ken
-----------------------
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. . I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Thanks,
Shane
* "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> scripsit: I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Have a look at this sample:
<URL:http://dotnet.mvps.org/dotnet/samples/controls/downloads/FontList.zip>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Ok... so I do have to draw it myself? That was the way I was attempting to
do it.
What does the drawfocus rectangle do then?
Thanks,
Shane
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uQ******** ******@TK2MSFTN GP11.phx.gbl... Hi,
Dim dsXML As New DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
dsXML.ReadXml(" http://msdn.microsoft. com/rss.xml")
dsXML.WriteXml( "rss.xml")
ListBox1.DataSo urce = dsXML.Tables("i tem")
ListBox1.Displa yMember = "pubDate"
ListBox1.DrawMo de = DrawMode.OwnerD rawFixed
End Sub
Private Sub ListBox1_DrawIt em(ByVal sender As Object, ByVal e As System.Windows. Forms.DrawItemE ventArgs) Handles ListBox1.DrawIt em
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(List Box1.Items.Item (e.Index), DataRowView)
dt = Date.Parse(dr.I tem("pubDate"). ToString)
s = dt.ToShortDateS tring
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
g.FillRectangle (Brushes.White, e.Bounds)
If CBool(e.State And DrawItemState.S elected) Then
g.FillRectangle (Brushes.LightB lue, e.Bounds)
End If
If dt < dtCompare Then
br = New SolidBrush(Colo r.Red)
Else
br = New SolidBrush(Colo r.Black)
End If
g.DrawString(s, ListBox1.Font, br, _
RectangleF.op_I mplicit(e.Bound s))
br.Dispose()
End Sub Ken
-----------------------
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Thanks,
Shane
BluDog,
I think according to Ken, I must manually draw it... It thought there might
be some other thing like drawfocusrectan gle....
If I just need to draw it then I can do that.
Thanks,
Shane
"BluDog" <ne**@nospam.bl udog.net> wrote in message
news:cd******** *************** *********@4ax.c om... On Thu, 8 Jul 2004 22:25:49 -0500, "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote:
I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item?
Thanks,
Shane
Can you post the code from your DrawItem sub please.
Thanks for the link...
I will check it out.
Danke,
Shane
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:2l******** ****@uni-berlin.de... * "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> scripsit: I have a listbox and I am drawing my items.
For some reason the selected item doesn't show a selection....
this seems to happen even if I tell it to draw focus rectangle.
What should I do to so a selected item? Have a look at this sample:
<URL:http://dotnet.mvps.org/dotnet/samples/controls/downloads/FontList.zip> -- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Hi,
I never had any luck with getting the drawfocusrectan gle to work.
Ken
-----------------
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:O0******** ******@TK2MSFTN GP11.phx.gbl... Ok... so I do have to draw it myself? That was the way I was attempting to do it.
What does the drawfocus rectangle do then?
Thanks,
Shane
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:uQ******** ******@TK2MSFTN GP11.phx.gbl... Hi,
Dim dsXML As New DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
dsXML.ReadXml(" http://msdn.microsoft. com/rss.xml")
dsXML.WriteXml( "rss.xml")
ListBox1.DataSo urce = dsXML.Tables("i tem")
ListBox1.Displa yMember = "pubDate"
ListBox1.DrawMo de = DrawMode.OwnerD rawFixed
End Sub
Private Sub ListBox1_DrawIt em(ByVal sender As Object, ByVal e As System.Windows. Forms.DrawItemE ventArgs) Handles ListBox1.DrawIt em
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(List Box1.Items.Item (e.Index), DataRowView)
dt = Date.Parse(dr.I tem("pubDate"). ToString)
s = dt.ToShortDateS tring
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
g.FillRectangle (Brushes.White, e.Bounds)
If CBool(e.State And DrawItemState.S elected) Then
g.FillRectangle (Brushes.LightB lue, e.Bounds)
End If
If dt < dtCompare Then
br = New SolidBrush(Colo r.Red)
Else
br = New SolidBrush(Colo r.Black)
End If
g.DrawString(s, ListBox1.Font, br, _
RectangleF.op_I mplicit(e.Bound s))
br.Dispose()
End Sub Ken
-----------------------
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message news:%2******** *******@TK2MSFT NGP10.phx.gbl.. . >I have a listbox and I am drawing my items. > > For some reason the selected item doesn't show a selection.... > > this seems to happen even if I tell it to draw focus rectangle. > > What should I do to so a selected item? > > Thanks, > > Shane > >
Glad I am not alone on something...
thanks Ken.
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:O4******** ******@tk2msftn gp13.phx.gbl... Hi,
I never had any luck with getting the drawfocusrectan gle to work.
Ken ----------------- "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message news:O0******** ******@TK2MSFTN GP11.phx.gbl... Ok... so I do have to draw it myself? That was the way I was attempting to do it.
What does the drawfocus rectangle do then?
Thanks,
Shane
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:uQ******** ******@TK2MSFTN GP11.phx.gbl... Hi,
Dim dsXML As New DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
dsXML.ReadXml(" http://msdn.microsoft. com/rss.xml")
dsXML.WriteXml( "rss.xml")
ListBox1.DataSo urce = dsXML.Tables("i tem")
ListBox1.Displa yMember = "pubDate"
ListBox1.DrawMo de = DrawMode.OwnerD rawFixed
End Sub
Private Sub ListBox1_DrawIt em(ByVal sender As Object, ByVal e As System.Windows. Forms.DrawItemE ventArgs) Handles ListBox1.DrawIt em
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(List Box1.Items.Item (e.Index), DataRowView)
dt = Date.Parse(dr.I tem("pubDate"). ToString)
s = dt.ToShortDateS tring
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
g.FillRectangle (Brushes.White, e.Bounds)
If CBool(e.State And DrawItemState.S elected) Then
g.FillRectangle (Brushes.LightB lue, e.Bounds)
End If
If dt < dtCompare Then
br = New SolidBrush(Colo r.Red)
Else
br = New SolidBrush(Colo r.Black)
End If
g.DrawString(s, ListBox1.Font, br, _
RectangleF.op_I mplicit(e.Bound s))
br.Dispose()
End Sub Ken
-----------------------
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message news:%2******** *******@TK2MSFT NGP10.phx.gbl.. . >I have a listbox and I am drawing my items. > > For some reason the selected item doesn't show a selection.... > > this seems to happen even if I tell it to draw focus rectangle. > > What should I do to so a selected item? > > Thanks, > > Shane > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: pothik05 |
last post by:
I can not make the DrawItem event to work on the CheckedListBox control. I
suggestion will be highly appreciated.
I have the following code. The code works for ListBox and the second item
(Two) is displayed in red in the ListBox but the CheckedLIstBox displays
everything in black (where it should be displayed as red).
Public Sub New()
MyBase.New()
|
by: Patty O'Dors |
last post by:
Hi
I have some code to create an ownerdrawn listbox (derived), and when I add
an item to it, the bold text of the first item (the title, 'Collections and
Maturities') mysteriously seems to get bunched up at the right, i.e. squashed
up! any idea why?
The main bit of the code is as such
// (in progressReporter.cs)
protected struct LBRow //a row of the listbox, whether it be the title or a
|
by: Danny van Kasteel |
last post by:
Hi,
I'm trying to make an ownerdrawn ListBox that can display a custom graphic
and 2 lines of text per item.
I have tried to set the following properties on a standard ListBox control:
DrawMode = OwnerDrawFixed
ItemHeight = 32
|
by: Richard Bond |
last post by:
Hi,
A colleague of mine has added a 60,000 array of strings to a listbox using
the addrange method.
He did this because it seemed the quickest method of getting 60,000 items
into the listbox.
He would now like different "text" and "value" properties for each item in
the listbox. Given the number of items, what would be the most efficient way
of doing this?
|
by: dan heskett |
last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some
custom "fields" and text layout.
Essentially it works, but I must be missing something big, conceptually,
because I get all kinds of screen artifacts and weirdness.
My general goal is: list item with a few areas for text, every other item
shaded a light color for readability, font color changes with selection. The
listbox is populated with custom structurs...
| |
by: Paul_Madden via DotNetMonster.com |
last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be
displayed in different colours for easy reading.
Have set ScrollAlwaysVisible and HorizontalScrollbar to true.
I Anchor the listbox T, L, R, B on the parent form
The string items held within the listbox are quite big, much longer than
could be displayed within the Listbox display area.
|
by: Paul_Madden via DotNetMonster.com |
last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be
displayed in different colours for easy reading.
Have set ScrollAlwaysVisible and HorizontalScrollbar to true.
I Anchor the listbox T, L, R, B on the parent form
The string items held within the listbox are quite big, much longer than
could be displayed within the Listbox display area.
|
by: Paul_Madden via DotNetMonster.com |
last post by:
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe is that as more and more
are added, population of the list box takes longer and longer. ie the first
10th of the item set are added much much quicker than the last 10th. THis
occurs with about 40,000 listbox items. My worry is the listbox may...
|
by: kiran.inbng |
last post by:
Hi All,
Iam trying to create a listbox with buttons/tree control as items in a
listbox(ownerdrawvariable) and iam having some problems.Below are my
questions,
1.Is there a equivavalent of DrawFrameControl(a win32 api) in C#.If not
how can button be created in the item rect
2.How to a create tree control or any other control inside a listbox
3.What will be the state of the item when drawitem handler is called
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |