473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

better component than ListVIew

Hi,

Several months ago i've asked some information about the best way how to
have some particular columns (progress bar, checkbox, images, color
picker,...) in a ListView component.

It seems that ListView is a complex component and a lot of people advise
to build a custom component but not from ListVIew itself.

Some use a datagrid component as base component, some build a component
from scratch, and so on.

I know that some will write that it is stupid to reinvent the hot water,
but it is for training purpose.

therefore i would like to know what is the component trend to improve
ListView features ? Datagrid, custom component, and so on...

thanks a lot,

Al.
Dec 26 '06 #1
5 1779
--== Alain ==-- wrote:
It seems that ListView is a complex component and a lot of people advise
to build a custom component but not from ListVIew itself.
In case ListView can't do what you need, it's better to create your own
component from scratch. Inherit from Panel, custom draw the entire
component sing double buffering. Capture the mouse and keyboard events
and process them yourself. It's quite a bit of work, but you'll have
full control, and none of the burdenful issues of the original ListView.
It's not nearly as hard to build such a custom component as it may first
seem, but it will take several days at the very minimum.

A few tips for you:

- Do this in the constructor to eliminate flickering due to double paint:
SetStyle(ControlStyles::Opaque, true);
SetStyle(ControlStyles::UserPaint, true);
SetStyle(ControlStyles::AllPaintingInWmPaint, true);
- Call ControlPaint::DrawFocusRectangle to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRectangle.Width, ClientRectangle.Height);
gr = Graphics::FromImage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscaled(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::VisualStyleElement and
VisualStyles::VisualStyleRenderer to render standard Windows elements on
the screen, such as a list view header, buttom, check box, tree
collapse/expand icons, and much more. They're only available in .NET
2.0+, but but .NET 1.x is so primitive you can't do any serious work
with it anyway.

Tom
Dec 27 '06 #2

"Tamas Demjen" <td*****@yahoo.comwrote in message
news:OL**************@TK2MSFTNGP03.phx.gbl...
--== Alain ==-- wrote:
>It seems that ListView is a complex component and a lot of people advise
to build a custom component but not from ListVIew itself.

In case ListView can't do what you need, it's better to create your own
component from scratch. Inherit from Panel, custom draw the entire
component sing double buffering. Capture the mouse and keyboard events and
process them yourself. It's quite a bit of work, but you'll have full
control, and none of the burdenful issues of the original ListView. It's
not nearly as hard to build such a custom component as it may first seem,
but it will take several days at the very minimum.

A few tips for you:

- Do this in the constructor to eliminate flickering due to double paint:
SetStyle(ControlStyles::Opaque, true);
SetStyle(ControlStyles::UserPaint, true);
SetStyle(ControlStyles::AllPaintingInWmPaint, true);
- Call ControlPaint::DrawFocusRectangle to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRectangle.Width, ClientRectangle.Height);
gr = Graphics::FromImage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscaled(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::VisualStyleElement and
VisualStyles::VisualStyleRenderer to render standard Windows elements on
the screen, such as a list view header, buttom, check box, tree
collapse/expand icons, and much more. They're only available in .NET 2.0+,
but but .NET 1.x is so primitive you can't do any serious work with it
anyway.
The VisualStyle stuff doesn't gracefully degrade when themes are disabled.
It doesn't work in design mode either.
>
Tom

Dec 27 '06 #3
Ben Voigt wrote:
The VisualStyle stuff doesn't gracefully degrade when themes are disabled.
It doesn't work in design mode either.
You mean if I use VisualStyleRenderer to paint my own list view header
or tree collapse/expand icons, it won't work on Windows 2000, or when XP
themes are disabled? I have to look into this.

Tom
Dec 28 '06 #4
thx a lot for your info.
But why to create it from Panel ?

Tamas Demjen wrote:
--== Alain ==-- wrote:
>It seems that ListView is a complex component and a lot of people
advise to build a custom component but not from ListVIew itself.

In case ListView can't do what you need, it's better to create your own
component from scratch. Inherit from Panel, custom draw the entire
component sing double buffering. Capture the mouse and keyboard events
and process them yourself. It's quite a bit of work, but you'll have
full control, and none of the burdenful issues of the original ListView.
It's not nearly as hard to build such a custom component as it may first
seem, but it will take several days at the very minimum.

A few tips for you:

- Do this in the constructor to eliminate flickering due to double paint:
SetStyle(ControlStyles::Opaque, true);
SetStyle(ControlStyles::UserPaint, true);
SetStyle(ControlStyles::AllPaintingInWmPaint, true);
- Call ControlPaint::DrawFocusRectangle to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRectangle.Width, ClientRectangle.Height);
gr = Graphics::FromImage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscaled(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::VisualStyleElement and
VisualStyles::VisualStyleRenderer to render standard Windows elements on
the screen, such as a list view header, buttom, check box, tree
collapse/expand icons, and much more. They're only available in .NET
2.0+, but but .NET 1.x is so primitive you can't do any serious work
with it anyway.

Tom
Dec 30 '06 #5
--== Alain ==-- wrote:
thx a lot for your info.
But why to create it from Panel ?
I'm not a professional .NET visual control developer, that's not my main
expertise. There are lower level classes to inherit from. I don't know
what others are using to implement totally custom painted components.

I used Panel to implement an image editor, a thumbnail viewer and a
special tree view (so unique that it couldn't be based on the standard
tree control).

Using Panel has a few advantages. It already has a graphics to provide a
drawing surface. It's a container for child controls, so you can easily
insert other controls on it. It has built-in double buffering in .NET
2.0. It has the ability to handle the scrolling automatically, by
showing horizontal and vertical scroll bars as needed. All you have to
do is provide the size of your virtual canvas, and if it doesn't fit, it
inserts the scroll bars automatically. The control already has useful
events and properties, such as a bevel and other visual styles.

I'm not that familiar with the .NET framework's component hierarchy.
Maybe someone else can suggest you a base to inherit from, depending on
your needs. I just found that Panel always works for completely custom
painted components, if you don't have a better idea. If you just want to
tweak a list view a little bit, inherit from ListView and implement the
custom painting of the items.

Tom
Jan 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: frank brown | last post by:
When I run the vstudio.net upgrade wizard on a VB6 project, it bombs with the following error: "Upgrade failed: Exception occurred: The referenced component ListView is missing a design time...
1
by: Tom John | last post by:
Hi I am trying to write a group of controls that interact. Basically, these controls are a TreeView, a ListView and a TabControl. By checking items within the TreeViewdifferent results will be...
4
by: Frank Rizzo | last post by:
Hello, I have a listview control with bunch of entries. When the user right-clicks on the item, I want a context menu to come up. So I created a ContextMenu instance and assigned it to...
2
by: Padu | last post by:
I'm looking for a component to make listviews (perhaps grid). I have two requirements for the component for two different situations I want to use it. In the first situation, I need a listview...
5
by: sethuganesh | last post by:
hi, i have created a sample window aplication in VB.NET.placed a listview component in the form ,written click and double click event for list view.But the events are not fired.is there any...
1
by: malpani.abhijit | last post by:
Hi, I am having a ListView component in my WinForm, when i add some images into it, it gives me a vertical scroll bar. What i want is, the horizontal scrollbar instead of vertical. Is there any...
0
by: --== Alain ==-- | last post by:
Hi, I'm currently working under VC++.NET 2005 and i'm deriving my custom control from ListView. I need your feedback to know in which direction should i develop this control. I've seen on...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
2
by: senfo | last post by:
I'm using a ListView control to display pictures similarly to how Windows Explorer displays pictures in "Thumbnails" view. The images are stored in an ImageList component. I would like to provide...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.