At the moment, I´m writing a C# - WPF - application, where I often need to show a few Data out of the database.
Now, my "problem" is, that I don´t want to use a datagrid, because it is already used very often in my app.
Is there any control to show data to the user "beautiful" instead of a datagrid?
ListView with a GridView as View looks pretty nice by default. (Also there is nothing stopping your from making a nice style for the DataGrid)
Related
I am totally new to programming in c# and have no previous experience with Object Oriented programming. I am teaching myself, so please I have many questions. I created a simple array that takes information from (STEP Text file) and displays it in a TextBox, now I am trying to put this information in Grid (like table) instead of showing them in a TextBox. I found Grid and Datagrid in the Toolbox window, but couldn't find DataGridView. I am using Visual Studio 2015. I would like to know:
How can I add DataGridView to my project?
Is there a simple code to put the information in a grid?
Since I am a beginner, please, be patient with me.
The reason is DataGridView is Windows Forms control and is available in Windows Forms project type only. You wont be able to use that in your WPF project. The equivalent in WPF is DataGrid.
As for the part regarding adding information in a grid, you will have to set the DataContext property of the DataGrid. For learning WPF, I would recommend to check out the two websites below:
https://wpftutorial.net/DataGrid.html
http://www.blackwasp.co.uk/WPFDataGrid.aspx
I am currently looking for what is best practise when creating a dynamic listview, this will contain a list of clients and once the user clicks this will expand a detailed expander style. I have in the past used user controls, adding a new one each time, however this caused performance issues.
Take a look at this page. This seems to be exactly what you want. Instead of a listview, it uses a datagrid.
I have a mysql database that I am using my Windows form application to view and fill data in.
I'm running into a problem when I try to use binding sources in a user control. All I'm doing is clicking and dragging a label from the data sources toolbar.
When I run the program, the label can't reference the fields in my database. The correct data sources are displayed at the bottom of the design view and in the Designer code.
But, when I do the same thing in the form, it works perfectly well.
What changes between the form data binding and the user control data binding? I've tried digging in the Designer code, creating an entirely new project so I don't have any messy code in the way.
Edit: The article,
Walkthrough: Creating a Windows Form user control that supports simple data binding
makes it look like I can simply drag an drop on the user control, no question asked. However, this does not work for me
Please forgive any silly words I may say. I am coming from a Actionscript3 background.
I am using "Visual C# 2010 Express".
I have a simple Form, in a WindowsForm Project, which currently holds just a Listbox. (Which I presume I will have to change to something else).
And I made myself a different display object (User Control) that is currently a Checkbox a title. (More will be added once I get over the hurdle below)
But I can't even get as far as Displaying the UserControl as a list.
I can't seem to find anywhere on the listbox to say "User this displayobject as the visual for listbox". I see tutorials saying "ItemsPanelTemplate" but I get error saying there is no such property for a Listbox.
I even tried making the Form in Design view and it is not in the list down the side of the GUI when I dragged as Listbox on screen.
Now I know how I would do this in pure Actionscript, but I dont know how to do this in Pure C#. Tutorials are not helping, as all the Microsoft site seems to try to give me is XAML (XML). and I am looking for C# code. So I have thrown in the towel and pleading for outside help.
Thank you for any help you can give.
It sounds like you want a list of items, each with a CheckBox and some descriptive text. Try using the CheckedListBox control. MSDN link.
This question also answers the question of how to do custom image drawing for each item in a ListBox. It may be helpful.
Edit after clarification:
Try embedding the UserControl in a ListView, rather than a ListBox.
References on embedding controls in ListViews:
C# listview - embedding controls
Adding button into a Listview in WinForms
You could also use a list of Panels, with each Panel hosting a UserControl.
C# List of Panels
But the real answer, as seen in the question's comments, is that Winforms doesn't have a convenient way to do this. This is a task much better suited to WPF.
You may check out freeware component Better ListView Express from ComponentOwl. It supports simple Details view without columns, two and three-state checkboxes, images and more...
They also offers full version with even more nice features like hierarchical and multi-line items.
I've seem some other posts regarding datagrids that allows grouping. I've downloaded the DevExpress DataGrid for Windows Forms but it really looks complicated. I actually need a Datagrid that derives from DataGridView as a lot of my data binding is code driven and uses the DatagridView classes.
I've managed to find this OutLookgrid on CodeProject, I was wondering if anyone used this before?
http://www.codeproject.com/KB/grid/OutlookGrid.aspx
I've downloaded the DevExpress
DataGrid for Windows Forms but it
really looks complicated.
Looking really complicated and being really complicated are not the same thing. I use the DX XtraGrid everyday and I can assure you its as complicated as:
gridControl1.DataSource = myDataTable;
.. if you want just a standard grid out of the box.