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
20
votes
7 answers

Cannot check box in DataGridViewCheckBoxColumn?

I'm creating a simple DataGridView with a check box column and a text column (more columns will follow, but this is the minimal working example that I'm trying to get working). When I run this code, the checkbox columns appears, but I can't check…
Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
20
votes
2 answers

Hyperlink cell in Winforms DataGridView

I have a datagridview with the following data. ContactType | Contact ------------------------------------ Phone | 894356458 Email | xyz@abc.com Here, I need to display the data "xyz@abc.com" as a…
Sandeep
  • 5,581
  • 10
  • 42
  • 62
19
votes
4 answers

How do I to get the current cell position x and y in a DataGridView?

I have a Windows form with a calendar which is hidden. I want to show the form right under the current cell of a DataGridView. The position changes according to the position of current cell. I don't want the current cell or current column, I want…
user1231584
  • 193
  • 1
  • 1
  • 4
19
votes
8 answers

DataGridView row's background color is not changing

I want to change the background color of the DGV's row based on particular condition at load even in Windows Form. But I can't see any change of color to any DGV's row. Could anyone tell me how can I solve this problem? private void…
Stardust
  • 1,115
  • 6
  • 22
  • 33
19
votes
5 answers

datagridview column index

I have a form with a DataGridView widget and I need to get the index of the column with the selected name. For example, let's say that I have a table with 2 columns: Name, Surname. I need a way to get index of the column name. The problem is that it…
harf
  • 191
  • 1
  • 1
  • 3
19
votes
2 answers

What is the correct way to use Entity Framework as datasource for DataGridView?

I tried setting DataSource via DataGridView Designer but it wasn't listed there and then I generated new datasource via wizard which generated DataSet. But now I have Entity Framework in my project + DataSet how can I use Entity Framework only...…
solujic
  • 924
  • 1
  • 18
  • 43
19
votes
2 answers

Binding to DataGridView - Is there a way to "bind" the background color of a cell?

I am binding a List to a DataGridView. One property of the SomeObject class will be a status code (ex. Red, Yellow, Green). Can I "bind" the status to the background color of a cell easily? How about binding to a tooltip also?
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
19
votes
11 answers

c# winforms - DataGridView Save position after reload

This is my code: private void getData(string selectCommand) { string connectionString = @ "Server=localhost;User=SYSDBA;Password=masterkey;Database=C:\data\test.fdb"; dataAdapter = new FbDataAdapter(selectCommand, …
bobik
  • 201
  • 1
  • 2
  • 4
19
votes
5 answers

How to set Cell value of DataGridViewRow by column name?

In windows forms, I'm trying to fill a DataGridView manually by inserting DataGridViewRows to it, so my code looks like this: DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvArticles); row.Cells[0].Value =…
user2612401
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();…
19
votes
4 answers

How to Casting DataSource to List?

I have the following method that load products on a DataGridView private void LoadProducts(List products) { Source.DataSource = products; // Source is BindingSource ProductsDataGrid.DataSource = Source; } And now I'm trying to…
Cristhian Boujon
  • 4,060
  • 13
  • 51
  • 90
19
votes
2 answers

BindingList<> ListChanged event

I have a BindingList<> of a class set to the DataSource property of a BindingSource, which is in turn set to the DataSource property of a DataGridView. 1. It is my understanding that any additions to the list will fire a ListChanged event which will…
Andy
  • 5,188
  • 10
  • 42
  • 59
19
votes
11 answers

DataGridView checkbox column - value and functionality

I've added a checkbox column to a DataGridView in my C# form. The function needs to be dynamic - you select a customer and that brings up all of their items that could be serviced, and you select which of them you wish to be serviced this time…
David Archer
  • 1,154
  • 6
  • 18
  • 34
18
votes
8 answers

Exporting datagridview to csv file

I'm working on a application which will export my DataGridView called scannerDataGridView to a csv file. Found some example code to do this, but can't get it working. Btw my datagrid isn't databound to a source. When i try to use the Streamwriter to…
PandaNL
  • 828
  • 5
  • 18
  • 40
18
votes
7 answers

How Do I Get the Selected DataRow in a DataGridView?

I have a DataTable bound to a DataGridView. I have FullRowSelect enabled in the DGV. Is there a way to get the selected row as a DataRow so that I can get strongly typed access to the selected row's values?
Damien
  • 1,463
  • 1
  • 18
  • 30