473,749 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1803
--== 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(Contro lStyles::Opaque , true);
SetStyle(Contro lStyles::UserPa int, true);
SetStyle(Contro lStyles::AllPai ntingInWmPaint, true);
- Call ControlPaint::D rawFocusRectang le to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRe ctangle.Width, ClientRectangle .Height);
gr = Graphics::FromI mage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscal ed(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::V isualStyleEleme nt and
VisualStyles::V isualStyleRende rer 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******** ******@TK2MSFTN GP03.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(Contro lStyles::Opaque , true);
SetStyle(Contro lStyles::UserPa int, true);
SetStyle(Contro lStyles::AllPai ntingInWmPaint, true);
- Call ControlPaint::D rawFocusRectang le to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRe ctangle.Width, ClientRectangle .Height);
gr = Graphics::FromI mage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscal ed(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::V isualStyleEleme nt and
VisualStyles::V isualStyleRende rer 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 VisualStyleRend erer 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(Contro lStyles::Opaque , true);
SetStyle(Contro lStyles::UserPa int, true);
SetStyle(Contro lStyles::AllPai ntingInWmPaint, true);
- Call ControlPaint::D rawFocusRectang le to paint your own focus rectangle.
- Here's how to ensure an off-screen bitmap for double buffering:
if(bmp == nullptr)
{
bmp = gcnew Bitmap(ClientRe ctangle.Width, ClientRectangle .Height);
gr = Graphics::FromI mage(bmp);
}
You paint everything to this bitmap, then you use DrawImageUnscal ed(bmp,
0, 0) to show it on the screen.
- Take a look at VisualStyles::V isualStyleEleme nt and
VisualStyles::V isualStyleRende rer 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
1341
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 license." Do I really have to install VB6 on my vstudio.NET workstation in order to upgrade VB6 projects? Won't this install lots of VB6 junk on my system that I'll never use? I really hope there's another way...especially since ListView...
1
1070
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 displayed on the ListView, selecting an item on the ListViewwill display it as a tab on the TabControl. These three controls work with data, properties and methods within a
4
3371
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 ListView.ContextMenu property. The problem is that the context menu comes up regardless of whether I right-click on the item or the empty space or the column header. I want it only to come up when the user right-clicks on an item. How can I
2
2210
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 that either allow to have an image on the background or a gradient background. The second application is to have a listview in "detail" mode or a grid (it will be read-only, therefore I'm not sure if I need a grid component). The only thing extra...
5
5179
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 property to be set for click event. Thanks, Ganesh
1
9340
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 way to hide the vertical scrollbars and display horizontal scrollbars?
0
943
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 internet a lot of similar controls, however i would like to understand a little bit more how to built such component...
12
3412
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. Very simple. I would like to create listviewitem's for display in a listview control. The listview items need to contain properties from Internet Explorer windows i've managed to collect into an arraylist.
2
4861
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 the ability to rotate the images and I'm having some issues. Basically, what I've tried is: lstViewImages.LargeImageList.Images.RotateFlip(RotateFlipType.Rotate90FlipNone); lstViewImages.Update();
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9333
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,...
0
9254
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 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...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
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...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
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
3
2217
bsmnconsultancy
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...

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.