ListView; Sort & Highlight columns - c#

I was wondering 2 things.
How can I make it so when I click on a row it selects both columns?
How can I make it so it auto sorts them when they click a column?
If C# doesn't allow this then is there any libs I could use or anything easier? Thanks.

If you mean your listview has 2 columns and you want to select the both of them on row selection, you can just set FullRowSelect=true.
For your second question check this Sorting ListView Items by Column Using Windows Forms

Related

How to limit column reorder to a few columns?

In my WPF application, I am using a DataGrid control. I allow the user to reorder columns. However, I have to ensure that the first two columns and the last column cannot be reordered.
All the columns are generated programmatically using new DataGridTextColumn().
I am wondering if someone can guide me on what I need to do to accomplish this? Thank you in advance for your help.
You can use the DataGrid.FrozenColumnCount Property to not allow the users to move columns.
However, if you look at the documentation, you will see that you can only do this for the first x columns from the left side of the DataGrid. For example, if you set the FrozenColumnCount to 2, the two left columns in the display are frozen.
Use DataGridColumn.CanUserReorder property (set tis property to false for columns, which can't be reordered).

DataGridViewComboBoxColumn in two tabs

I am using C# in Visual Studio 2010. I have two tabs. In each tab, I have a DataGridView (1 and 2) table with a ComboBoxColumn (1 and 2). I would like to make it so that when the user selects an index from the ComboBoxColumn1 in tab1, tab2 indicates that selection in one of the columns of that DataGridView in text form. Does anyone know how to do this? Any help would be much appreciated.
Thanks
Use the DataGridView.CellValueChanged event to catch the change in DataGridView 1 and then use that value to update DataGridView 2.

DevExpress cascading comboboxes in datagridview

I have a datagridview bound to a datasource, and in each row in the grid there is a category, product, and quantity. I want to filter the products in each row according to the selected category.
I'm using C# and DevExpress. How can I do this?
Please refer to the How to filter a second LookUp column based on a first LookUp column's value article which explains how to implement this feature.
Depending on how You want to filter you can set
gridView1.OptionsCustomization.AllowFilter = true;
This will display an additional filter row in your grid that will allow you to filter all columns by any text you want;
Or you can make sure that gridView1.OptionsCustomization.AllowFilter is set to true. Then there should be little icon on your column header (visible in right top corner when you move cursor over the column header) that will display filter after you click it.

DomainUpDown control inside the GridView

I want to add DomainUpDown control inside a DataGridView as a separate column. Each time a new row is added, I want that DomainUpDown control also be added. I also want to know when the user click the DomainUp or DomainDown button in DomainUpDown control for each row. Is it possible or not? I am using language vb.net/C#. I want to do this in winform not in ASP. Any help or suggestion please!!!
All you need to do/know is how to add an unbound column to an already data bound DataGridView, because from your description you are trying to add a column to a grid which already contains other data bound columns. In fact it would be easier if you had such column in the DataTable, also because with unbound columns you need to make a slightly bigger effort to populate and save the data from/to somewhere.
anyway it should be possible, MSDN explains it here: How to: Add an Unbound Column to a Data-Bound Windows Forms DataGridView Control

c# datagridview gridlines

I have a gridview that I wish to display gridlines only on certain rows.
I want them to be on each column, but only after every 4 rows. Is this possible?
Thanks.
You can use the DataGridView.CellPainting event.
You can always user javascript (JQuery) to select wanted columns on table generated by gridview asp.net. After selecting this columns, set their right-border to wanted value or color.
If you don't want to use javascript, you can use RowDataBound eventHandler. If your columns are template fields, you can find wanted control ( e.Row.FindControl("ControlName")) and it's parent ( e.Row.FindControl("ControlName").Parent ). I am not sure, but I think that parent should be wanted cell and then you can set borders. You can try something like this, I haven't tried this.

Categories

Resources