Click here to Skip to main content
Click here to Skip to main content

A basic DataListView implementation

, 21 Nov 2005
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
-

Comments and Discussions

 
GeneralNew feature and bug fix PinmemberSGInut14-Nov-05 14:42 
GeneralRe: New feature and bug fix PinmemberVlad Stanciu21-Nov-05 7:16 
GeneralNice job. nm Pinmembereyoung703-Dec-04 10:33 
GeneralIf there are any problems Pinmembervladstanciu2-Dec-04 8:57 
GeneralRe: If there are any problems Pinmembersxzhang221-Mar-05 9:07 
GeneralRe: If there are any problems PinmemberVlad Stanciu24-Mar-05 20:42 
GeneralRe: If there are any problems Pinmembersxzhang225-Mar-05 2:41 
GeneralRe: If there are any problems PinmemberVlad Stanciu25-Mar-05 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.8.140827.1 | Last Updated 21 Nov 2005
Article Copyright 2004 by Stanciu Vlad
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid