Resolved Best way to display tabular data

Godfrey

New member
Joined
Dec 17, 2023
Messages
4
Programming Experience
10+
So I'm learning Windows Forms and I'm trying to display something as simple as project list (generated automatically from file structure) with a few buttons next to each project name, like "archive" and "delete". Clicking on a project name should close project list WinForm, and open project's WinForm where the actual work is done. It's a little bit similar to how PyCharm works, though not entirely.

Now I came up with a few solutions but none of them feels right.

First is obviously DataGrid. It looks awful, doesn't look designed for such purpose, and expected behavior of clicking on a cell is being able to edit it's contents, not being brought to entirely new window. While technically I did make it work the way I want, it just doesnt look or feel right leave alone professional. But maybe there's a way to style DataGrid so that it wouldn't look like DataGrid at all?

Next idea was ListBox or ListView. Again it does not look like it's designed for such purpose. I can list all the projects all right, but buttons next to them in a separate "column" is a problem.

Next idea, just use a TableLayoutPanel, two columns, each project's name in it's own TextBox in the first column, all the buttons in the second. First, I am not sure about performance, some users may have hundreds of projects. And overall it just looks too much of a hassle for something that simple, but maybe only because I'm new to WinForms. But if I won't find a better solution I will probably go with this one.

Another idea was to find a free library for that. ObjectListView seemed to be perfect for what I need, but GPL license is a dealbreaker (not my call).

And my final idea was to just ask people with more experience which is why I am here ;) Any suggestions?
 
DataGrid is considered obsolete. It was just put into WinForms to entice VB6 programmers to move into use .NET.

Use the DataGridView. It lets you create columns with buttons.

A few quick asides:
The classical Windows way of having actions for a row, is to have a menu item at the top of the form dynamically populate when you select the "Action" menu as you select a row. Later these menu items became toolbar buttons. When right clicking and the Context Menu became more popular, having the actions when you right click on the click on the row in a context was also common.

The naive WinForms implementation often created by beginners is to have a dropdown column in a DataGrid or DataGridView that has the actions. (Also this was pretty common in early web apps that had tabular data and JavaScript access to the mouse button clicks was not available.)

Just my observation, but it looks like people are experimenting with a web like UI when a row is selected, a small palette of buttons appear at the end of the column. I've seen this in the past in some forum software a few years ago, and most recently in the latest versions of Outlook.

Consider the consequences of having column buttons and the user "misses" and clicks on the wrong row.
 
Last edited:
Hey Skydiver, thanks for your reply.
So I take it DataGridView is a commonly accepted way to do something like this, I just need to change the column type and toy around with it's looks? That's great news. Also your "quick asides" are very useful, now I think I may have been too tunnel visioned on my particular approach.

Just my observation, but it looks like people are experimenting with a web like UI when a row is selected, a small palette of buttons appear at the end of the column. I've seen this in the past in some forum software a few years ago, and most recently in the latest versions of Outlook.

Yup, PyCharm (Python's IDE) that I take inspiration from, also does something like that, button's appear only on a row that's MouseOver'ed. I wasn't a big fan of this approach although I can see how it helps to prevent accidental misclicks to some extent. Also makes the UI look less cluttered. So I may go for it after all at some point later, after I get the basics down and working.

Not having any buttons at all and just using context menu on the item/row user wants may also be a viable solution, I can't believe I didn't think of it myself. In such case would there still be a reason to use DataGridView?

Thanks again for your help.
 
A ListView will also let you right click on a row.
 

Latest posts

Back
Top Bottom