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
18
votes
13 answers

DataGridView vertical scrollbar not updating properly (Forms bug?)

I've encountered a bug (I assume) in .NET 3.5. When adding rows to a DataGridView using Rows.Add(), while the DGV is disabled, the vertical scrollbar doesn't update properly. Consequently you can't scroll all the way to the bottom of the DGV using…
ReturningTarzan
  • 1,068
  • 1
  • 13
  • 23
18
votes
4 answers

How to build a DataTable from a DataGridView?

I may well be looking at this problem backwards but I am curious none the less. Is there a way to build a DataTable from what is currently displayed in the DataGridView? To be clear, I know you can do this DataTable data =…
Refracted Paladin
  • 12,096
  • 33
  • 123
  • 233
18
votes
2 answers

C# Bind DataTable to Existing DataGridView Column Definitions

I've been struggling with a NullReferenceException and hope someone here will be able to point me in the right direction. I'm trying to create and populate a DataTable and then show the results in a DataGridView control. The basic code follows, and…
Timothy
  • 4,630
  • 8
  • 40
  • 68
18
votes
3 answers

populating datagridview with list of objects

I have a List that contains a series of transaction objects. What I'm trying to do is to display these transaction objects in a Datagridview control on loading a form, basically the Datagridview should represent something of a transaction register…
morris295
  • 517
  • 1
  • 7
  • 21
18
votes
3 answers

How to disable Null image in DataGridView image column when populated from DataTable

I have an existing application with a new requirement to show an image in a DataGridView cell to denote whether the record has a specific flag associated with it or not (not user editable, this comes from the DB). If there is a flag, I show the…
Jim
  • 6,753
  • 12
  • 44
  • 72
18
votes
14 answers

DataGridView Selected Row Move UP and DOWN

How can I allow selected rows in a DataGridView (DGV) to be moved up or down. I have done this before with a ListView. Unfortunetly, for me, replacing the DGV is not an option (curses). By the way, the DGV datasource is a Generic Collection. The…
Silly Rabbit
  • 308
  • 2
  • 4
  • 11
17
votes
7 answers

DataGridViewComboBoxColumn adding different items to each row .

I am building a table using the DataGridView where a user can select items from a dropdown in each cell. To simplify the problem, lets say i have 1 column. I am using the DataGridViewComboBoxColumn in the designer. I am trying to support having…
leora
  • 188,729
  • 360
  • 878
  • 1,366
17
votes
8 answers

how to sort a datagridview by 2 columns

How do I sort a DataGridView by two columns (ascending)? I have two columns: day and status. If I need to sort by one column, I do: this.dataGridView1.Sort (this.dataGridView1.Columns["day"], ListSortDirection.Ascending); But for two?
user1112847
  • 287
  • 1
  • 5
  • 10
17
votes
11 answers

c# very slow populating the datagridview

I'am populating a datagridview from a datatable. While populating the columns and rows, I also format it at the same time, this cause the datagridview to load very slowly, is there a work around for this problem?
user1030916
  • 171
  • 1
  • 1
  • 3
17
votes
11 answers

DataGridView ID Column Will Not Hide

I have a DataGridView bound to an ObjectDataSource some of the columns are hidden including the ID column. The problem is that the ID column shows up even when its visible property is set to false. Has anyone run into this problem before? Setting…
Lukasz
  • 8,710
  • 12
  • 44
  • 72
17
votes
7 answers

How to suspend a DataGridView while updating its columns

How can I suspend a .NET DataGridView from displaying anything while I update its Columns? Here's my current code. It works ok, but it is very slow on the foreach loop; you can see the horiz scroll bar grow slowly as each column is added. I'm…
Lane
  • 2,669
  • 3
  • 25
  • 38
17
votes
2 answers

Conditional DataGridView Formatting

I have a DataGridView. I set its .DataSource prop to be an BindingList of my own objects: a BindingList I then created some columns for it.. DataGridViewTextBoxColumn descColumn = new DataGridViewTextBoxColumn(); …
KevinDeus
  • 11,988
  • 20
  • 65
  • 97
17
votes
1 answer

DataGridView Image for Button Column

I'm trying to add a clickable image/button to a datagridview button column. The image/button will be an icon for play or stop. If the user clicks the play button a service on the system is started, if the user clicks the stop button a service is…
Brad
  • 1,979
  • 7
  • 35
  • 47
17
votes
6 answers

How do I add records to a DataGridView in VB.Net?

How do I add new record to DataGridView control in VB.Net? I don't use dataset or database binding. I have a small form with 3 fields and when the user clicks OK they should be added to the DataGridView control as a new row.
John
17
votes
4 answers

How to make a DataTable from DataGridView without any Datasource?

I want to get a DataTable from DataGridView of the Grid values. In other words DataTable same as DataGridView Values
Mobin
  • 4,870
  • 15
  • 45
  • 51