Questions tagged [datagridview]

DataGridView is a Windows Forms control used to display and edit tabular data.

DataGridView is a Windows Forms control found in the .NET Framework starting at version 2.0. It is used to display and edit tabular data from many different kinds of data sources. It provides a rich set of features such as sorting, filtering, grouping, and editing data.

Useful links

20349 questions
29
votes
4 answers

Changing DataGridView Header Cells' Text Alignment And The Font Size

I'm trying to change the text alignment and the font size of a DataGridView. All the Columns are created programatically at runtime. Here's the code.. private void LoadData() { dgvBreakDowns.ColumnCount = 5; dgvBreakDowns.Columns[0].Name =…
Isuru
  • 30,617
  • 60
  • 187
  • 303
28
votes
4 answers

At least one of the DataGridView control's columns has no cell template

I'm getting that exception. System.InvalidOperationException was unhandled Message=At least one of the DataGridView control's columns has no cell template. Source=System.Windows.Forms StackTrace: at…
Hooch
  • 28,817
  • 29
  • 102
  • 161
28
votes
3 answers

Event that fires during DataGridViewComboBoxColumn SelectedIndexChanged

I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second one is ComboBoxCol(DataGridViewComboBoxColumn). How can I change the value of TextBoxCol when ComboBoxCol changes its selected index…
Kalix Diona
  • 469
  • 1
  • 5
  • 10
28
votes
15 answers

Slow performance in populating DataGridView with large data

I am using a BindingSource control (reference here) to populate my DataGridView control. There are around 1000+ records populating on it. I am using threading to do so. The DataGridView performs very slow in this case. I tried to set DoubleBuffered…
VJOY
  • 3,752
  • 12
  • 57
  • 90
27
votes
13 answers

Adding Text to DataGridView Row Header

Does C# allow you to add a String to a RowHeader in a DataGridView? If so, how is it accomplished? I'm writing a Windows Form to displayed Customer Payment Data for the year so far. The ColumnHeaders display January, February, March, etc... and…
Bailz
  • 605
  • 2
  • 8
  • 17
27
votes
3 answers

What's better to use: a DataGrid or ListView for displaying large amounts of data?

I want to display >50000 rows in a table. Which is the best control to use: a DataGrid or a ListView (in details view)? Which of these controls will have the better performance?
alex dee
  • 327
  • 1
  • 3
  • 4
27
votes
2 answers

DataGridView Validation & Changing Cell Value

I would like to manipulate a cell in my DataGridView when it is validating so that if the user enters a value that is not valid for the database, but is easily converted to valid data, the program will change the value to an appropriate one. I am…
Micah
  • 429
  • 1
  • 5
  • 11
27
votes
1 answer

Using DataGridViewRowCollection object in LINQ

I'd like to use a DataGridViewRowCollection in a LINQ expression using extension methods and lambda expressions. Unfortunately, the extension methods are for types IEnumerable, which DataGridViewRowCollection doesn't implement. The funny thing…
Mashmagar
  • 2,556
  • 2
  • 29
  • 38
27
votes
7 answers

how to bind datatable to datagridview in c#

I need to bind my DataTable to my DataGridView. i do this: DTable = new DataTable(); SBind = new BindingSource(); //ServersTable - DataGridView for (int i = 0; i < ServersTable.ColumnCount; ++i) { …
animekun
  • 1,789
  • 4
  • 28
  • 45
26
votes
3 answers

Enabling and disabling a cell in a Datagridview

I am using a DataGridView control for displaying some data. I need to enable some data and disable some data dynamically based on some values in the grid. Can anyone tell me how to do it?
Senthil
26
votes
7 answers

How can I display a DateTimePicker in a DataGridView?

Is there any way to put a DateTimePicker control in the DataGridView? I checked all the possible properties but it give option of checkbox, combo box etc, but not the DateTimePicker.
Furqan Sehgal
  • 4,917
  • 33
  • 108
  • 167
26
votes
8 answers

How can we do pagination in datagridview in winform

I want to show 10 records per page in a datagridview on a window form and user must click next button to show next 10 records. Is it there some property in DataGridview or do i need to create a custom control. What i need to do to achieve this.
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
26
votes
2 answers

DataGridView Event to Catch When Cell Value Has Been Changed by User

I have a Winforms app written in C#. In one of my DataGridViews I have set all columns except one called 'Reference' to ReadOnly = true; I want the application to know when a User has changed anything in the 'Reference' column, but all the events I…
PJW
  • 5,197
  • 19
  • 60
  • 74
26
votes
5 answers

Adding values to specific DataTable cells

I'm wondering if it's possible to add values to specific DataTable cells? Suppose I have an existing dataTable and I add a new column, how would I go about adding to the new column's rows without overwriting the existing columns' rows? As far as I'm…
Winz
  • 449
  • 2
  • 6
  • 18
25
votes
8 answers

Disabling or greying out a DataGridView

Is there any easy way to disable/grey out a DataGridView? For instance when doing dgv.Enabled = false The appearance of the dgv does not change. I have seen people appending the following: dgv.forecolor = gray dgv.columnheader.forecolor =…
Jeb
  • 3,689
  • 5
  • 28
  • 45