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.
Related
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
I am using a "DevXpress.XtraGrid.GridView" and I have a column there which is bound to a boolean data. This column shows check boxes to represent values. I need to show "YES/NO" instead of check boxes. Please advice me.
Thanks for helping,
Kushan Randima.
This is how I do it in code in one of my tools. This is a dynamic SQL Query tool and it returns a checkmark or red X beside the query result, at runtime. You can also do this through the designer but this is done in code.
This is for Winforms, but the low level GridView should be the same code for WPF (I am not positive).
First, in the Data Grid GridView designer, I add a column (mine is "IsError" column). Then in my form constructor or InitializeForm() I do this:
RepositoryItemCheckEdit checkEdit = gridOutput.RepositoryItems.Add("CheckEdit") as RepositoryItemCheckEdit;
checkEdit.PictureChecked = global::Gyrasoft.Common.DX.Properties.Resources.exclamation;
checkEdit.PictureUnchecked = global::Gyrasoft.Common.DX.Properties.Resources.accept;
checkEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.UserDefined;
gridViewOutput.Columns["IsError"].ColumnEdit = checkEdit;
The resources, of course, have to be valid images.
Basically you add a repository item (RepositoryItemCheckEdit) and set CheckStyle to UserDefined, and assign the checkEdit to the gridView column. You can add the same checkedit to multiple columns. It is simply for rendering or editing.
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).
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).
I would like to order contents in a column when user clicks column header on the Syncfusion GridList control. Does anyone have any idea on how I might achieve this using C#?
I don't have them installed right now but it should be something like this:
GridControl.TableDescriptor.AllowSort = true;
This should make the columns sortable, thus when clicking on the column header it will order them.