Hierarchical Data Grid View Events

Hierarchical Data Grid View Events Rating: 6,3/10 6510 votes
  1. Data Grid View In Vb
  2. Hierarchical Data Grid View Events In C#
  3. Hierarchical Data Grid View Events In California

A few advantages of using a hierarchical grid is that they are flexible, easy to absorb, can incorporate more elements and they do not have fixed boundary lines. So now that you know everything about a hierarchical grid arrangement, if you come across a site where data are arranged not according to any of the other grid types i.e. Hierarchical Data Binding 30-31 Creating Hierarchical Grid 31 Export Service 31-37. Handling client side Key events 78 Samples 79-80 Client-side Reference 81. Delete, sort, and group data. GridView for ASP.NET Web Forms includes advanced features that enable developers to build intuitive, professional-looking Web applications quickly. Link for csharp, asp.net, ado.net, dotnet basics and sql server video tutorial playlists http://www.youtube.com.

20 Jan 2015CPOL
Nested or Master Detail or Hierarchical DataGridView for winforms

Introduction

Data Grid View In Vb

In my previous article I have explained about how to create a DatagGridView helper class using c# click this link to view my previous article.

I have extended the DatagGridView Helper class to create a Nested DatagGridView. Few days before one of codeproject member asked a question on how to create a Nested or Master Detail or Hierarchical DataGridView for winforms. I started searching in Google but badly I didn’t get any result for nested DataGridView .I started working on creating a Nested DataGridView sample program which should be useful to all. As a result I have created a Nested DataGridView and you can find the source code from this article. My aim is to create a simple and easy program for users. User can download the code and can customize depend on their requirement.

Why we need Nested or Hierarchical DataGridView

In real time projects like Order Management, Production management and etc. we need to display the data in the hierarchical result.

For example let’s take Order Management project for a restaurant. Let’s consider four peoples going to a restaurant to have their lunch. The waiter from the restaurant will give a menu card to select the item to place an order. Now in a Table total 4 peoples are sitting. In a restaurant management usually for all tables there will be a unique Table Id or name. All 4 peoples will select their item need from menu card and place the order to serve their food. In restaurant management for each order we will create a unique Id in an Order Master table and all the item details related to the order in Order Detail table. Let’s see an example structure of the order.

Why we need Master and Detail Table? To avoid the duplicate data we can use the master Detail table relation to store our data. For example for every order there will be one waiter and one Table so if we didn’t use the Master Detail table relation the output will be like this below.

Here we can see that Order No, Table ID, Waiter Name and order Date has been repeated. To avoid this duplicate data we will create a Master and Detail relation tables .See the below table for Master and Details.

Order Master Table

Here we can see the duplicate data has been stored in separate table as a Order Master Table.

Order Detail Table

Here we can see all the item details of order in separate table. But in the detail table we have used the Order NO for a relation to the Master table. Using the relation we can combine both the table and produce the out output.

Normal grid result:

The result can be shown without using the Hierarchal grid output .But we have to display the duplicate result as below.

We can also merge the same data and show the result like this below table. But the output is not much good and not easy to view and understand.

Let’s see now the hierarchical output of the same result.

Now this final result looks much better then all. It will be easy to view the master and detail of all records.

Here is my sample output of hierarchical Datagridview.

Pinnacle studio 14 ultimate collection serial number

Same like Order Management in Restaurant projects we will have Bill Master and Detail, Account Master and Detail. Item Master and Detail, Inventory Master and Detail. In production projects we will have Production Order Master and Oder Detail, Finished Good Receipt Master and Detail, Finished Goods Issue Master and Detail and etc. Same like this in our all real time projects we will use the Master and detail relation to display our data.

Using the code

As I told you in this article that I have used and extended my DataGridView helper class to create a Nested DataGridView. You can view my DataGridView helper class details from my article.

In my DGVhelper class I have added the below functionality to create the nested grid.

  • ImageCoulmn
  • DGVMasterGridClickEvents
  • DGVDetailGridClickEvents

User can use all events like CellClick, CellContentClick and etc for both Master and Detail grid.

I have created two separate list class to populate the master and detail result. In form load called the method to add the details to each list class.

I have created both Master and Detail Datagridview programmatically (Dynamically) Using my ShanuDGVHelper Class.

Master Grid Setting: In Form load I have called this method to create a master DataGridView at runtime.

In my code I add the comments before each line to explain its use.

Cell Click Event: I have called this above method to create a Cell click event for master DataGridView.

This event will be used for the master grid Image click event. In this Event i will get the Order No and filter the result from DataTabledetail .Display the final Dataview result to Detail DataGridView.

Hierarchical Data Grid View Events In C#

In cell click event if the image column is clicked. I will change the image to Expand and Collapse depends on the selected image name.

If the image is selected to Expand then I will make visible of the detail DataGridView.

In cell click event I will get for the current selected Order No. This order No will be used in “DataView” to filter only the selected order result. The Final result will be bind to the Detail DataGridView.

Detail Grid Setting: In Form load I have called this method to create a Detail DataGridView at runtime.

In my code I add the comments before each line to explain its use.

Hierarchical data grid view events in california

Detail Grid Cell Click Event: I have called this above method to create a Cell click event for Detail DataGridView.

Data

This event will be used for the Detail grid Cell Click Event. In cell click of Detail grid i will get the each cell text and display in the Messagebox.

Points of Interest

This program explains the basic functions to create single level Hierarchical DataGridView. This same functionality can be used to create multi level Hierarchical DataGridView.

History

Version 1.0 - > 2014-12-02.

Active6 years, 4 months ago

Am working on a .net 3.5/Winforms application.I need to show a datagridview with hierarchical data in the datagrid.

Hierarchical Data Grid View Events In California

For example, master rows will have an expand/collapse icon..and when the user clicks on a master row, it should expand and show the child row details in the grid.

Using the Infragistics sample example at http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=1665, am now able to see Master/Child data in my ultragrid.

Now my next task is to :

1.Show editable textboxes in the child grid having order details.[Note: I tried this but did not work for me: this.ultraGrid.DisplayLayout.Bands[1].Columns[3].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Edit;]

2.When the user hits submit button, read these textbox values and push it to the database.

Could you please let me know if this is possible and how to go about it?

Any sample example will be really helpful.

Thanks.

Jimmy
JimmyJimmy
92610 gold badges33 silver badges49 bronze badges

1 Answer

Take a look at this

EDIT::

For Infragistics UltraGrid, refer

Community
Sangram NandkhileDataSangram Nandkhile
8,61915 gold badges70 silver badges103 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged winformsdatagridviewinfragisticsultragrid or ask your own question.