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

Loading CSV into DataGridView

Here is my code to load a CSV file into a my DataGridView in my WinForms application: private void loadCSV(string path) { if (!File.Exists(path)) { MessageBox.Show(this, "File does not exist:\r\n" + path, "No File", MessageBoxButtons.OK,…
Ozzah
  • 10,631
  • 16
  • 77
  • 116
3
votes
2 answers

Bind Multiple Lists to a DataGridView

I have two static lists which are to be bound to a DataGridView along with two button fields. I could only bind one list and a button field. Is it possible to bind more than one list to the DataGridView? ServiceController objSAVAdminService = new…
Arjun
  • 1,049
  • 6
  • 23
  • 37
3
votes
1 answer

Datagridview new row disappear

in my DataGridView I click on a new row, then new empty row appears at the bottom, it is standard behaviour and there is no problem. So I fill the row and click on the last empty row and here is the problem, the row I just filled disappears. Cells…
pesaak
  • 131
  • 2
  • 10
3
votes
1 answer

C#: Accessing datagridview1 from a backgrounder thread

Im trying to access ui controls on the main thread from a backgroundworker thread. I know this is a well known issue but i cannot find any information on how to access a datagridview in particular from the backgrounder thread. I know the code to…
hWorld
  • 185
  • 2
  • 3
  • 9
3
votes
4 answers

How to find index of a row based on the object value using C#?

I have a datagridview, and I want to remove a particular row from it (datagridview is not data bound). To remove, I need the index of the row. Datagridview items are all objects. At this moment, all I have is the id (a property) of the object. I…
nawfal
  • 70,104
  • 56
  • 326
  • 368
3
votes
1 answer

Ability to drag between two datagrid item

I have two datagridview in the same form. Is there a way to drag items between them? Can the drag update the DB inside the data source? Thanks
peroxide
  • 696
  • 1
  • 4
  • 19
3
votes
2 answers

How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?

Developing In: c# winforms without any Database Connections Description: In my DataGridView, columns were dynamically generated.At some point some of the columns need to be DataGridViewLinkColumn property. I was tried in many ways but didn't achive…
kik
  • 247
  • 1
  • 5
  • 15
3
votes
1 answer

Updating text of a button in a datagridview

I have a DataGridView on a winform. I am dynamically adding DatagridViewButtonColumn in the load method of form with button name as btnAction and text displayed on it as "Process". So, every row in the grid would have this Process button in the last…
user74042
  • 729
  • 5
  • 14
  • 28
3
votes
3 answers

Data Binding Cells Of DataGridView

I have a function that databinds one of the cells of the DataGridViewRow passed as argument. public static void DataBindCells(DataGridViewRow row) { DataGridViewComboBoxCell priceModes = row.Cells["ColumnPriceMode"] as DataGridViewComboBoxCell; …
Akshay J
  • 5,362
  • 13
  • 68
  • 105
3
votes
1 answer

Changing row color in not-active DataGridView

What's the best way of changing some rows back color in DataGridView, when it's not active?? In "real" world I would like to use it for formatting all DataGridView rows after button click, depending on some criterias. To reproduce behaviour, please…
mj82
  • 5,193
  • 7
  • 31
  • 39
3
votes
2 answers

How do I sort a DataBound column in a DataGridView on a column header click?

I believe this should be handled automatically. I am binding a DataGridView to an array of objects: public class Entity { public string Name { get; set; } public int PrimaryKey { get; set; } } Binding the grid: public void…
Ian R. O'Brien
  • 6,682
  • 9
  • 45
  • 73
3
votes
3 answers

search in datagridview C# winfom

I want to put a search option in DataGridView, i.e., User types the string or int in TextBox and similar records the DataGridView should be highlighted. I tried it using KeyPress event but didn't work. if (Char.IsLetter(e.KeyChar)) { for…
Nhuren
  • 503
  • 2
  • 10
  • 29
3
votes
1 answer

Problem with data binding on custom datagridview column

I have a problem with binding data to custom DataGridView column. I created column that shows rating by stars-images accordingly to the int value it gets from database. When i test it by adding rows manually it works perfectly. But when i bind data…
3
votes
5 answers

How to I prevent 'self' drag and drop in a datagridview?

I'm implementing drag and drop functionality between two datagridviews. This works as intended with one exception: it is possible to drag and drop within the same datagridview. This results in duplicated rows. I want to limit the functionality so…
Simon
  • 6,062
  • 13
  • 60
  • 97
3
votes
0 answers

C# WinForms DataGridView OutOfMemoryException after creating form multiple -> not collected by GC

I have a form with DataGridView in it. I open and close (create and dispose) form multiple times and it's causing memory problems. GC is not collecting it, and after couple hours of working OutOfMemoryException occurs. Given form has couple of…