Questions tagged [datagridviewcolumn]

In WinForms DataGridViewColumn class represents a column in a DataGridView control.

In WinForms DataGridViewColumn class represents a column in a DataGridView control.

516 questions
85
votes
7 answers

How can I right-align text in a DataGridView column?

How can I right-align text in a DataGridView column? I am writing a .NET WinForms application.
Jayantha Lal Sirisena
  • 21,216
  • 11
  • 71
  • 92
53
votes
5 answers

How to set DataGridView textbox column to multi-line?

How to let "DataGridViewTextBoxColumn" in DataGridView supports Multiline property?
Wahid Bitar
  • 13,776
  • 13
  • 78
  • 106
51
votes
5 answers

Get a DataTable Columns DataType

DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn(gridColumn1, typeof(bool))); I was expecting the result of the below line to include info about the DataColumns Type (bool): ?dt.Columns[0].GetType()
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
31
votes
10 answers

How to hide column of DataGridView when using custom DataSource?

I have a small app in c#, it has a DataGridView that gets filled using: grid.DataSource = MyDatasource array; MyClass hold the structure for the columns, it looks something like this: class MyDatasource { private string column1; …
mglog
  • 311
  • 1
  • 3
  • 3
28
votes
8 answers

How to get cell value of DataGridView by column name?

I have a WinForms application with a DataGridView, which DataSource is a DataTable (filled from SQL Server) which has a column of xxx. The following code raises the exception of ArgumentException was unhandled. Column named xxx cannot be…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
19
votes
10 answers

C# DataGridViewButtonCell set buttons text

I need to add my DataGridViewButtonCell to Column, and I need to name each other with different names. But I didn't find any text properties. Can anyone help me, please? i do that stuff DataGridViewButtonCell b = new DataGridViewButtonCell();…
13
votes
2 answers

How can I center the heading in a column on a DataGridView?

I have a strange problem and it's probably a simple fix, but after much research, I cannot seem to find a solution. I have a DataGridView on which I'm trying to center the column headings, but the result is a left bias in the centering—almost like…
Keith
  • 131
  • 1
  • 1
  • 3
8
votes
4 answers

Binding a object with a sub objects as properties to a datagrid

I am working with an object which has sub objects within (see example below). I am attempting to bind a List to the datagrid. When I bind the List<>, in the cell that contains the subObject, I see the following value ...…
user26901
8
votes
1 answer

How to Change Format column in Datagridview to date type for this value

For example, I have a value like this : 41607.2069444444; 41607.2068402778; 41607.2072222222; this is calculation of dateTimeOrigination from CDR, in excel where i change the format cell to type date, its work and this is 11/29/2013 4:58:42 AM. My…
7
votes
1 answer

Mixing cell types in a DataGridViewColumn

Is it possible to have both DataGridViewComboBoxCells and DataGridViewTextBoxCells in a single DataGridViewColumn? Or am I absolutely restricted to having one type per column?
Smashery
  • 57,848
  • 30
  • 97
  • 128
7
votes
5 answers

Datagridview remove all columns

Is it possible in a single hit to remove all columns from a datagrid? I know I could loop though and remove them one by one, or remove the whole thing and create it. But it is possible to simply clear columns and leave the grid in place so users…
DevilWAH
  • 2,553
  • 13
  • 41
  • 57
7
votes
1 answer

DataGridViewCheckBoxColumn: how to update bound DataSource on property changed instead of on validation

I've got a BindingList binded as the data source of a DataGridView; one of the TSource properties is binded to a DataGridViewCheckBoxColumn, but the data source is updated not when a click on the checkbox occurs, but when the focus on the checkbox…
Notoriousxl
  • 1,540
  • 1
  • 16
  • 27
7
votes
10 answers

Search for value in DataGridView in a column

I want the user to be able to search for a number in a column in the DataGridView (dgv). The dgv can hold many records. Each record has a Project Number. So I want the user to be able to search for a project number in column Project Number. The…
FJPoort
  • 225
  • 2
  • 7
  • 16
6
votes
6 answers

DataGridView header alignment slightly to left even after setting it to MiddleCenter

I'm setting the following properties for a DataGridView in my C# project ... sampleDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; sampleDataGridView.ColumnHeadersDefaultCellStyle.Alignment =…
Ahmad
  • 12,886
  • 30
  • 93
  • 146
6
votes
5 answers

DataGridView resizeable columns, but last column can't be resized bigger?

For c = 0 To grd.Columns.Count - 1 grd.Columns(c).Resizable = DataGridViewTriState.True Next c That allows all the columns in my DataGridView to be resizable EXCEPT the last column. Why? I DO get the little resizable-mouse-pointer... but you…
Bonnie
  • 161
  • 1
  • 3
  • 6
1
2 3
34 35