Click here to Skip to main content
12,447,242 members (67,703 online)
Click here to Skip to main content
Add your own
alternative version

Stats

53.1K views
183 downloads
19 bookmarked
Posted

A basic DataListView implementation

, 21 Nov 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
It implements an object that is intended for data viewing; the idea was to derive from a ListView.

Sample Image - DataListView.jpg

Introduction

This is my first article, so please do not be hard on me Smile | :) . The purpose was to make the base of a data viewing control like the one found in Microsoft's applications, or the one proposed by the "magic controls". So the main goal was the looks defined by looks and a basic functionality.

The main idea

The main idea was to extend a ListView, and work with its properties. Customize it to show only lists, inhibit read only to false, and full row select to true. Also, make it possible for a data source, just add a new object into the control to hold the data and make some functions to process the given data source. Make a row in the control for any row in the data source... Implement some properties for the control to be functional, properties like: SelectedItem or SelectedItems[].

Nothing hard ... except the interception of an row drawing event. Here is the big problem, if you want a nicer drawing. So the code must intercept the draw item message and process it custom. In order to intercept this you must set the control style so that the desired message to be passed to you and not be default handled.

For the control to be useful, I had to implement some rudimentary table styles ... if it can be named so Smile | :) . There are some functions made to make it all possible in an easy code snippet.

The control is easy to use, like the DataGrid:

DataSet dataSet = new DataSet();
DataListView dataListView = new DataListView();
// let windows designer place the control (dataListView) on the screen...
// initialize dataSet with some data...
dataListView.DataSource = dataSet; // show the data on the control
dataListView.DataMember = "TableNameInDataSet"; // set the data member

Instead of ending

The code is not meant to be "the best", it is easy to understand and can be heavily improved in all ways. I end this article with my usual statement : "I hope you understand...".

Anyway if you like my idea and you ever decide to use my control, you are free to modify it as you wish, but you can mention me somewhere there on the about window Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Stanciu Vlad
Architect
Romania Romania
-

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralNew feature and bug fix Pin
SGInut14-Nov-05 14:42
memberSGInut14-Nov-05 14:42 
GeneralRe: New feature and bug fix Pin
Vlad Stanciu21-Nov-05 7:16
memberVlad Stanciu21-Nov-05 7:16 
GeneralNice job. nm Pin
eyoung703-Dec-04 10:33
membereyoung703-Dec-04 10:33 
GeneralIf there are any problems Pin
vladstanciu2-Dec-04 8:57
membervladstanciu2-Dec-04 8:57 
GeneralRe: If there are any problems Pin
sxzhang221-Mar-05 9:07
membersxzhang221-Mar-05 9:07 
GeneralRe: If there are any problems Pin
Vlad Stanciu24-Mar-05 20:42
memberVlad Stanciu24-Mar-05 20:42 
GeneralRe: If there are any problems Pin
sxzhang225-Mar-05 2:41
membersxzhang225-Mar-05 2:41 
GeneralRe: If there are any problems Pin
Vlad Stanciu25-Mar-05 20:09
memberVlad Stanciu25-Mar-05 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 21 Nov 2005
Article Copyright 2004 by Stanciu Vlad
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid