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
4
votes
1 answer

C# - How to populate a .net DataGridView programmatically?

I need to populate a .net DataGridView from a collection physically (without data binding) in C#. That is, I should use foreach loops and iterate through the collection while creating a row for each object and a cell for each property. I have…
user366312
  • 16,949
  • 65
  • 235
  • 452
4
votes
1 answer

How to DataGridViewComboBoxColumn set value from dataset

Let's say i have two tables: work_hours work_hours_id | date | _project_id 1 1.2. 10 2 1.2. 11 3 1.2. 10 project project_id | project_name 10 pr1 11 …
JanOlMajti
  • 1,387
  • 4
  • 22
  • 34
4
votes
1 answer

Avoid adding duplicate datarows

In my Windows Forms Application, basically I have two DataGridViews. I want to select rows from right one and add selected rows to the left. The right DataGridViewhas a checkbox column. See the image : For example : Click the first row and…
user1108948
4
votes
1 answer

Reset DataGridView blank row if user clicks in that row and takes focus off that row

If a user clicks the blank row at the bottom of a DataGridView and moves focus away from the DataGridView, the row click in now is in a state that indicates a change is made to that row. Is it possible to tell the DataGridView to un-mark this row as…
Emad-ud-deen
  • 4,734
  • 21
  • 87
  • 152
4
votes
2 answers

DataGridViewComboBoxCell takes several clicks to bring up menu for another cell. Advice on speeding up the process?

In order to bring up the menu for a DataGridViewComboBoxCell, I first have to click: 1) the row of the cell I want to edit 2) within the cell I want to edit 3) the I want to edit again, in order to open the ComboBox for the cell. If another cell is…
Frosty840
  • 7,965
  • 12
  • 50
  • 86
4
votes
5 answers

DataGridView does not refresh after dataset update vb.net

I have a vb.net form with a dataGridView The dataGridView data source is the dgvTableAdapter with this sql statement SELECT membres.ID, membres.refere_par, bands.titre, membres_1.prenom & ' ' & membres_1.nom AS reference_nom FROM ((bands…
pec
  • 614
  • 3
  • 12
  • 28
3
votes
3 answers

Is it possible to show a selection border rather than back-colour in a DataGridView?

My DGV has row BackColors set to various colours based on business logic. When a user selects the row the colour changes to the selected row BackColor thus obscuring the pre-set colour. I would like to preserve the original colour when a row is…
Simon
  • 6,062
  • 13
  • 60
  • 97
3
votes
1 answer

Cannot assign datagridview.columns[i].Width property

I'm writing a method that will resize the columns in a datagridview so that all the data is visible, and the columns completely fill the datagridview. What I'm doing is: 1) Set the DataGridViewAutoSizeColumnsMode to AllCells. This will show all…
CurtisHx
  • 746
  • 3
  • 11
  • 30
3
votes
1 answer

Change item of Datagridviewcombobox programmatically VB.NET

Dim cListItems As New System.Collections.Generic.List(Of Combobox_values) If ds.Tables("items_prices").Rows(0).Item("item_selldozen") > 0 Then Dim item_selldozen As String =…
John Nuñez
  • 1,780
  • 13
  • 35
  • 51
3
votes
1 answer

How to display rows as columns in DataGridView?

I'm trying to display set of data which have retrieved from the sql database using a datagridview in VS 2008. But I need to display data vertically rather than horizontally. This is what I have done at the beginning. con.Open(); SqlCommand cmd =…
Urban_cd7765
  • 33
  • 1
  • 3
3
votes
2 answers

DataSet Filter between 2 dates

Hello I posted a few days ago a similar question and I was told to use a dataset filter to filter my datagridview. I've had a go but I'm struggling to work out how to do it. I'm trying to filter a deadline column in a datagridview by 2…
Rob
  • 1,479
  • 5
  • 18
  • 24
3
votes
2 answers

C#: How to handle "self-references" for tables within DataGridView?

Situation: In my database I have a table in which records may reference other records in the same table. Every record has a unique numeric ID (auto-ID column) and a nullable column IDRef which may contain the ID of the record to be referenced. Now,…
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
3
votes
1 answer

Faster Method to Making DataGridViewRow's non-Visible

I'm using the following code to set a bunch of DataGridViewRow elements to be invisible. The rule I am using is to check the associated datasource for a boolean flag. If the flag is true, the row will be displayed. If not, it will be invisible. The…
Kashif
  • 865
  • 2
  • 12
  • 33
3
votes
1 answer

Limiting DataGridView cell multi selection to only column or row

I have a DataGridView with a number of columns and rows. I have MutliSelect enabled, but this allows selection of all cells. I want to limit the selection vertically, horizontally, full row or full column, but never a mix of both. The user can…
Corey
  • 1,177
  • 4
  • 16
  • 24
3
votes
2 answers

Cloning a GUI component

I need some help as Im relatively new to C#. Im basically trying to clone a datagridview component properties(the row/column content is different). Basically I have a tab page control... and at run time if the user wants to add another table, a new…
Magikarp
  • 492
  • 6
  • 19