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.

471 questions
72
votes
6 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
  • 20,611
  • 10
  • 65
  • 90
50
votes
5 answers

How to set DataGridView textbox column to multi-line?

How to let "DataGridViewTextBoxColumn" in DataGridView supports Multiline property?
Wahid Bitar
  • 12,467
  • 12
  • 74
  • 99
47
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
  • 52,213
  • 20
  • 153
  • 256
31
votes
9 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
23
votes
6 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
  • 21,678
  • 35
  • 151
  • 304
17
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();…
11
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
  • 111
  • 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

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,430
  • 1
  • 15
  • 27
6
votes
5 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
  • 11,274
  • 24
  • 79
  • 132
6
votes
4 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
  • 2
  • 6
6
votes
6 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
  • 195
  • 2
  • 6
  • 16
5
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
  • 49,979
  • 30
  • 90
  • 123
5
votes
1 answer

Validation on a single DataGridView column

How can I perform validation on a particular DataGridViewTextBoxColumn column in my DataGridView, so that a user is required to enter a value into it?
Abid Ali
  • 1,583
  • 7
  • 25
  • 62
1
2 3
31 32