Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


General Advice

Posted on 2004-08-22
Medium Priority
Last Modified: 2010-04-15
I'm an asp/ developer and new to windows forms development.

I want to know the best way to display a list of data - columsn and rows with some columns containing a button which I can attached some event to.

I have been looking at using the datagrid for this but it seems very hard to get buttons in there which makes me think for such a common task I must be using tht wrong concept.

Any thoughts?


Question by:daveamour
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 10

Expert Comment

ID: 11864817
I prefer the ListView to the DataGrid for displaying a single relation.  Instead of having a button, you can respond to the ListView.DoubleClick event.
LVL 19

Author Comment

ID: 11864847
Will this work with rows having more than 1 column?  This is what I need.


LVL 10

Accepted Solution

eternal_21 earned 150 total points
ID: 11865529
Yes, the ListView can have multiple columns.  It looks like Windows Explorer when you are in View -> Details mode.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 19

Author Comment

ID: 11867431
Oh ok thats interesting.  Can this have columns with buttons in too?


Expert Comment

ID: 11870820
Here are the type of coluumns officially supported by the DataGrid:

Bound column Allows you to specify which data source field to display. Allows you to specify the format of that field, using a .NET formatting expression.  

Hyperlink column Displays information as hyperlinks. A typical use is to display data (such as a customer number or product name) as a hyperlink that users can click to navigate to a separate page that provides details about that item.  

Button column Allows you to add a button for each item in the grid and define custom functionality for that button. For example, you might create a button labeled "Add to Shopping Cart" that runs your custom logic when a user clicks it. You can also add predefined buttons for Select, Edit, Update, Cancel, and Delete functions.  

Edit, Update, Cancel column Allows you to create in-place editing. For more details, see "Editing Items" below.

Template column Allows you to create combinations of HTML text and server controls to design a custom layout for a column. The controls within a template column can be data-bound. Template columns give you great flexibility in defining the layout and functionality of the grid contents, because you have complete control over how the data is displayed and what happens when users interact with rows in the grid.  

There are implementations of a DropDownList you can find on the INternat as a Template Column.

Overall the DataGrid can do some very powerful things. See MSDN and Search on DataGrid for a number of excellent columns:

And take the advice in my BLOG. It discussed what you need to do explicitly. It is here:

You need MSDN and Safari (at a minimim).

Kind Regards,
Damon Wilder Carr, Chief Technologist and CEO
.NET SIG Leader - New York Software Industry Association (NYSIA

80 Broad Street
5th Floor
New York, NY 10004

Voice              212.837.7788
Fax                212.859.7359
LVL 19

Author Comment

ID: 11870875
Damon - are you talkking about the DataGrid used in  I believe that this is quite different from the one used in Windows Forms which is what we are discussing here!
LVL 19

Author Comment

ID: 11878813
Thanks eternal

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question