C# Listview adds an extra column header in Details view - c#

I have ListView, where I'm adding just 2 columns with some data. the view I have set is details view.When I run the application, I see a third column header in the end, which appears to be an extra column. So how can I avoid this third column/ column header coming in the output and just show 2 columns.

My guess is that you do not see an extra column, but that your ListView simply is wider than your two columns.
Make sure your two columns take up all the space in your listview by either making them wider or setting up the last column (your second one) to use up all available horizontal space (something like width="*" or so).

Related

UWP - Matrix With Grid

I first would like to say that I am fairly new to UWP, and my experience with Android is probably leading some some assumptions on my end. There may be a better way about this, but so far I have been trying to use the Grid class, but it doesn't seem to work in a way that I would expect.
Basic Idea
I am trying to create a UWP application with the ability of organizing elements in a matrix, where each row and column represents some category, and whatever element that is within both row and column categories is placed in that cell. One or more elements can be listed in each matrix coordinate. An image for reference is below:
To give a more clearer/specific example, let's say the Elements were Employees, rows were Teams, and columns were disciplines (Testing, Dev, Management)
Comparing different category-types can be useful for displaying information, but this will have greater importance beyond just names, so this is only a simplified example. Also, as shown in the example, the number of rows and columns is determined by the number of categories there are for each respectively (e.g. # rows = # teams and # columns = # disciplines).
I don't have any code to show, simply because this isn't so much an error problem as it is a conceptual problem.
My Questions
How would I be able to filter what elements are bound to a cell by their Row/Column? Is this even possible?
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
How do I bind columns and rows to their respective list of categories?
e.g. whenever I add another Column Category, a new empty column will be generated.
I appreciate your help and time!
For your scenario, the better way is using DataGrid to replace.
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
You could use binding way to specific current element in which column and row, but you need to calculate before preparing data source for Grid panel.
whenever I add another Column Category, a new empty column will be generated.
If you use DataGrid, it will generate Column base on your item's new filed. Here is code sample that your could refer.

How to freeze columns and rows in WPF Grid

I'd like to "freeze" the columns and rows in WPF.
I want to implement a table (state machine), where in the first row are states and in first column are commands. The rest of the cells are filled with events.
To improve usability, I'd like to keep the first row and first column visible all the time, so even at the very bottom of the table the states and commands are visible.
The DataGrid offers this kind of functionality but DataGrid cells don't look flexible enough. I'd like to use Grid.
The ScrollViewer is basically what I need, but i haven't figured out how to use it for multiple Grids at the same time.
Is there any way to freeze first row and first column (at the same time)?
I don't think that there is no way to freeze columns or rows of a Grid. But you can use 4 Grids. Syncronize the Column and Rowsize with SharedSizeGroup.

Set the visibility of a column that has been grouped (single column)

I am grouping data in a grid by two different columns.
One of the columns needs to be retained as visible and the other needs to be removed from the grid.
I have set "ShowGroupedColumns" to false as it automatically handles the column chooser etc.
But I cant seem to figure out how to make the one I want to retain visible.
Is there any way, with ShowGroupedColumns set to false that I can have it grouped by column and have the column in the grid too?
Thanks
The same problem have been already discussed in DevExpress Support Center:
Display individual columns, even if they are grouped

add another column header on top to C# datagridview winform

I have a bounded datagridview with a lot of columns (around 40) and I'm wondering if I can add another column header on top of the default headers made with the SQL query. So it would look like a multi-row column header with some spanned columns.
I've seen some solutions by painting custom column headers but they involve creating all the columns. What if I leave the default headers made with the SQL query and just add a spanned column on top of it, is that possible?
DataGridView has no support for spanned columns. You will need to either look at third party, custom rendering, or a second control parked just above your grid.

hide columns by Id in gridview in asp.net

I have the asp.net application where I am having the editable grid view with the edit,Delete,Add options. this grid having as usual Template fields . I want to hide some columns. I know i can do that by using columns index. but i don't want to follow it. instead I want to hide columns by Id. this is because if in my application further I need to add more columns then there is need to change the code gain and again in the core. so I am choosing this way. Bu as i found <asp:TemplateField /> does not contain Id attribute. so it is become impossible for me to hide <asp:TemplateField/> by Id. any remedy for this ?
You can always do it using column header text. Run a loop through columns of the grid view and compare header text of the column with the constant declared and hide the column, this way, if you are adding any number of columns before or after the column will not affect the code.
Maybe create a div with an id inside a template field and hide that div with client code.
Perhaps just have a different grid markup for each "view" you want to show to the user, so one grid with all the columns, and another with limited columns.
I am assuming you would always be binding the same data to the grid (regardless of whether you are hiding/showing columns), so then you would just need some logic in your code to determine what "view" you want to show the user (i.e. what grid you want to bind to).

Categories

Resources