ListView control: Selecting only the text
|
|
Thread rating:  |
Nando - 28 Jul 2008 04:33 GMT When an item gets the focus in a ListView control, both the text and the icon get selected. Is there any way I can have only the text shaded and not the icon? Similar to what you see for the little icons under View->Project Browser. Thanks!
Jeff Johnson - 28 Jul 2008 06:37 GMT > When an item gets the focus in a ListView control, both the text and the > icon get selected. Is there any way I can have only the text shaded and > not the icon? Similar to what you see for the little icons under > View->Project Browser. Thanks! I assume you meant Object Browser. If so, it turns out that that is NOT a list view; it is just a list box (owner-drawn, I'm sure). So the answer is, no, you can't do this with a list view (unless you go owner-drawn).
Nando - 28 Jul 2008 19:33 GMT "Jeff Johnson" WROTE:
>> When an item gets the focus in a ListView control, both the text and the >> icon get selected. Is there any way I can have only the text shaded and [quoted text clipped - 4 lines] > list view; it is just a list box (owner-drawn, I'm sure). So the answer > is, no, you can't do this with a list view (unless you go owner-drawn). Thanks Jeff, Interesting.., so VB6 does not provide a control that can do this? All I need is what the standard Listbox offers, plus an icon (16x16) per item and no icon shadow when selected.
Jeff Johnson - 28 Jul 2008 22:25 GMT > Thanks Jeff, Interesting.., so VB6 does not provide a control that can do > this? All I need is what the standard Listbox offers, plus an icon (16x16) > per item and no icon shadow when selected. Nope, nothing out-of-the-box. You might be able to make something close with the flex grid, but if you can't turn off the grid lines (never tried it) then it'll look butt-ugly.
Nando - 30 Jul 2008 10:43 GMT >> Thanks Jeff, Interesting.., so VB6 does not provide a control that can do >> this? All I need is what the standard Listbox offers, plus an icon [quoted text clipped - 3 lines] > with the flex grid, but if you can't turn off the grid lines (never tried > it) then it'll look butt-ugly. Any lightway control besides grid? Or some very-simple sample code online so I can emulate an owner-drawn?
Jeff Johnson - 30 Jul 2008 18:21 GMT >>> Thanks Jeff, Interesting.., so VB6 does not provide a control that can >>> do this? All I need is what the standard Listbox offers, plus an icon [quoted text clipped - 6 lines] > Any lightway control besides grid? Or some very-simple sample code online > so I can emulate an owner-drawn? There's a sample of using owner-draw in a list box on vbaccelerator.com. It wouldn't be that hard to draw an icon in the list item. One thing about that code (unless he updated it after I sent him email a long time ago) is that when it draws an item highlighted it doesn't use the color for highlighted text, so you end up with black (normal) text on a blue background. It's simple to fix; I just wanted to point out what to look for.
Nando - 31 Jul 2008 01:27 GMT > There's a sample of using owner-draw in a list box on vbaccelerator.com. > It wouldn't be that hard to draw an icon in the list item. Great! I found it here: <http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/Owner_Dr aw_Combo_and_List_Box/article.asp> (hopefully that's the one you meant).
I downloaded the EXE demo and gave it a try. First I had to install the DLL and OCX:
COPY vbalODCL6.ocx %SystemRoot%\System32\ COPY SSubTmr6.dll %SystemRoot%\System32\ REGSVR32 /S %SystemRoot%\System32\vbalODCL6.ocx REGSVR32 /S %SystemRoot%\System32\SSubTmr6.dll
The control works great. It does not shade the icon when selected. This seems to be what I need. However I was hoping to get some idea from the code, so I can code my own, since all I wanted was the standard features of VB6 Listbox plus the ability to show an icon wth no shadow. However there is a lot of code behind it (even seems to be using subclassing - something I just have a little idea about). I may just use the compiled OCX instead.
> One thing about that code (unless he updated it after I sent him email a > long time ago) is that when it draws an item highlighted it doesn't use > the color for highlighted text, so you end up with black (normal) text on > a blue background. It's simple to fix; I just wanted to point out what to > look for. I didn't see any bugs reported under the BugTracker, and the list of updates does not say anything about it. Hope Steve fixed it (last update is shown as 19 Dec 2002).
Jeff Johnson - 30 Jul 2008 18:23 GMT >>> Thanks Jeff, Interesting.., so VB6 does not provide a control that can >>> do this? All I need is what the standard Listbox offers, plus an icon [quoted text clipped - 6 lines] > Any lightway control besides grid? Or some very-simple sample code online > so I can emulate an owner-drawn? Oh, I forgot: have you looked at the Image Combo that comes with the common controls v2? I don't think I've ever used it, so I can't tell you if it shades the icon when an item is selected or not. Hell, I don't even know if you can display it in list box mode (as opposed to dropdown mode), but it's worth a look.
Nando - 31 Jul 2008 01:29 GMT > Oh, I forgot: have you looked at the Image Combo that comes with the > common controls v2? I don't think I've ever used it, so I can't tell you > if it shades the icon when an item is selected or not. Hell, I don't even > know if you can display it in list box mode (as opposed to dropdown mode), > but it's worth a look. Interesting...., you got me curious on that Image Combo (I didn't even know of its existence until today). Well I gave it a try and found out that it does shade the icon when selected (just like its cousin the Listview - I guess that's runs in the family :( I also didn't find any properties to change the mode of the combobox to a listbox. However, I will definitely use that control in the near future. Thanks for that info.
Jan Hyde (VB MVP) - 29 Jul 2008 11:22 GMT "Nando" <nospam@no.spam>'s wild thoughts were released on Mon, 28 Jul 2008 18:33:28 GMT bearing the following fruit:
>"Jeff Johnson" WROTE: > [quoted text clipped - 9 lines] >Thanks Jeff, Interesting.., so VB6 does not provide a control that can do >this? A grid control.
J
>All I need is what the standard Listbox offers, plus an icon (16x16) >per item and no icon shadow when selected. -- Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Nando - 30 Jul 2008 10:50 GMT >>"Jeff Johnson" WROTE: >> [quoted text clipped - 18 lines] >>All I need is what the standard Listbox offers, plus an icon (16x16) >>per item and no icon shadow when selected. Thanks Jan, The grid does not seems to be a lightweight control for this task. Please let me know of a very-simple sample code online so I can create my own owner-drawn.
Jan Hyde (VB MVP) - 30 Jul 2008 11:45 GMT "Nando" <nospam@no.spam>'s wild thoughts were released on Wed, 30 Jul 2008 09:50:06 GMT bearing the following fruit:
>>>"Jeff Johnson" WROTE: >>> [quoted text clipped - 22 lines] >task. Please let me know of a very-simple sample code online so I can >create my own owner-drawn. And the listview IS lightweight?
-- Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Nando - 31 Jul 2008 01:42 GMT >>>>All I need is what the standard Listbox offers, plus an icon (16x16) >>>>per item and no icon shadow when selected. [quoted text clipped - 4 lines] > > And the listview IS lightweight? I would use the Listview if I could just turn off that feature that shades/distorts the icon when an item gets selected.
MikeD - 31 Jul 2008 02:19 GMT >>>>>All I need is what the standard Listbox offers, plus an icon (16x16) >>>>>per item and no icon shadow when selected. [quoted text clipped - 7 lines] > I would use the Listview if I could just turn off that feature that > shades/distorts the icon when an item gets selected. Maybe it's just me, but that really seems pretty minor. If the ListView meets all your other needs except for that one (IMO) LITTLE thing, just live with it. It doesn't affect anything in your app functionally, right? It's just a cosmetic thing. If you ask me, you appear to spending a lot of time on something that at most you should have spent 10 minutes looking into. Just an opinion.
 Signature Mike Microsoft MVP Visual Basic
Nando - 31 Jul 2008 04:10 GMT >> I would use the Listview if I could just turn off that feature that >> shades/distorts the icon when an item gets selected. [quoted text clipped - 5 lines] > time on something that at most you should have spent 10 minutes looking > into. Just an opinion. Thanks Mike, I have always used the Listbox or the ListView control, but I had to bring up this issue since large screens and high desktop resolutions are widely popular now and 16x16 pixels are so small that the standard shade on them makes them distorted and unrecognizable (this distinction it may actually be important for a section of my app). Originally I saw that icons under Object Browser didn't have this problem, so I thought there was a way to turn the icon shading off. But it turned out it cannot be done since it was not a ListView (now I know).
Until I started this thread I didn't even know about the existence of other controls, neither about user-drawn controls. But I have learned to ask about any issues, because often I get surprised on how easy it to address them instead of learning to live with them. You know, one of those seems one don't know until one asks.
Jan Hyde (VB MVP) - 31 Jul 2008 12:17 GMT "Nando" <nospam@no.spam>'s wild thoughts were released on Thu, 31 Jul 2008 03:10:55 GMT bearing the following fruit:
>>> I would use the Listview if I could just turn off that feature that >>> shades/distorts the icon when an item gets selected. [quoted text clipped - 20 lines] >instead of learning to live with them. You know, one of those seems one >don't know until one asks. Seems to me that if the icon is so vital to identifying a row in the listview then this could be resolved by having a column containing text that does the same job.
-- Jan Hyde (VB MVP)
https://mvp.support.microsoft.com/profile/Jan.Hyde
|
|
|