Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VB

DataToolbar

4.50/5 (2 votes)
7 Jul 2014CPOL5 min read 17K   926  
DataToolbar leads the standard DataNavigator to a higher level.

Visual Studio Project, Documentation and Help Files

Image 1

Image 2Image 3   Image 4Image 5

Introduction

Every time a developer codes a data driven application, he has to provide his end user with data management functions like 'create new record'. Up to the newer .NET Framework Microsoft includes a standard control DataNavigator in his Visual Studio toolbox to help the developer. But if you examine the functionality of this control, you will find that there are a couple of functions missing.

What is about selecting records by a condition (Filter). What about sorting a.s.o. Due to this I developed my own control the DataToolbar and a second one (sister control) the advanced Statusstrip.

Image 6

What can the DataToolbar control do for you?

The DataToolbar control takes the idea from Microsoft® with its Data Navigator control to a new upper class of data management functions that can be easily handled by the end user.

End User Functions

  • Manual move to a record (first, previous, next , last)
  • Automatically move from record to record (Fast Forward/Fast Rewind) with adjustable speed
  • Show current record position, total amount of records and amount of filtered records
  • Create a new record
  • Duplicate existing record (current one)
  • Reject data changes (current, filtered or all records having changes)
  • Save pending changes manually by a click
  • Automatically save pending changes before activation of other actions like record movement
  • Bookmark and jump to a specific record
  • Filter records by in build user friendly filter condition generator
  • Store up to 5 Filter condition values for later use of predefiend Filter
  • Sort records by in build user friendly sort condition generator
  • Show Data Table and current record state information by text and by image indicator
  • Intelligent enabling and disabling of toolbar items

Developer Functions

  • Data Object/Database independend due to usage of parent Forms Bindingsource and TableManager Object.
  • Change Back color and Background image
  • Align Toolbar items (left, centered, right)
  • Set Button size (small, medium, big)
  • Get workflow information of activities by special event with unique Activity ID
  • Be able to kill activities
  • Special Form/Control is dirty function including DataGridView control
  • Get Error information by special event with unique Activity ID
  • Send message information direct to separate sister control advancedStatusstrip if necessary use the inbuilt Progressbar of the Statusstrip control
  • Prepare control with set of custom properties

The control has an inbuilt Windows Help File and comes with a big set of documentation files. These files are in the PDF and RTF format and can be used by the developer in his own documentation.

There are three different files:

  • DataToolbarManual_EN is a Textdocument of the Windows Help file.
  • DataToolbarDeveloper_EN is a document with deep explanation of the controls code.
  • DataToolbar_EN.chm - the help file.

Please find these files in the directory Documentation in the ZIP file.

Background

To understand the code of the control, you should be familiar with VB.NET and ADO.NET.

Using the Code

It is quite normal that we will find code snippets in this section but the control has more than 2200 lines of code and I think to show it here will break the space of this article. All code is deeply commented and explained in the document DataToolbarDeveloper_EN on a spread of 95 Pages! Therefore I surrender to show code here.

Download DataToolbarDeveloper_EN.pdf

This may give you an impression of the document:

Image 7

In the ZIP file, you will find a Testproject the controls project and in the BIN directory of the Testproject, you find the DLL of the sister control advancedStatusstrip. I like to publish this control in a separate article as soon as possible later on.

Points of Interest

Examining the code, you will learn how to work with ADO and databound controls on Windows Forms (Bindingsource a.s.o.). There is a special solution for the answer of an often asked question "How to code a dirty flag for a form?" and an answer to the question "how can a context menu control contain a Listview?"

Data object independend? What does that mean? If you drag some Data Objects like a Table or Column from the Visual Studio Dataobject Toolbox onto the Form than VS automatically creates several classes:

  • The Dataset to  store the data intermediatly
  • The Bindingsource to manage the databound controls
  • The TableAdapterManager and the TableAdapters for the special Data Tables.

The creation of the this classes is based on the handling of data transactions of the different types of databases (data providers) all different comands are encapsulated within this classes. This is one of the magic of using the ADO Objects. With the Bindingsource and TableAdapter the developer is able to code a database independend data management. The negative page of this benefit is that he is restricted by the possibilities and properties of the Bindingsource and the TableAdapter. This leads to the decision to use direct SQL commands and direct database communication via the .Net System.Data Objects in the case where flexibility and total control is neccessary.

If you like to have total control and flexibility you may not use the DataToolbar Control! But in my experience in most of the situations your decision to use the control will fit your needs.

If you like how I have solved the task to give the developer a chance to interact with the control by properties or to interact with the controls process (workflow) and to get detailed error information, feel free to make it similar. It depends on more than 20 years of my coding experience.

History

Notice: Documentation will only be changed for major updates

3.03.5300 2014/07/03 - Minor changes

  • DataToolbar_Load event changed. isDirty Controls are monitoring DataGridView as well
  • Sub isDirtychanged, automatic DateTimeStamp value for UpdateColumn added
  • Icons to the DropDownButton Menu items added
  • Text of the article corrected

3.03.5301 2014/07/07 - Medium changes

  • Filter storage functionality implemented.
  • Help File updated.
  • Developer documentation updated.
  • Article updated (thank you to Mika)

Upcomming:

  • August 2014: German Help file.
  • August 2014: new Article advancedStatusstrip.

 

License

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