datagridview

Data confusion - Selecting data in one DataGridView based on selection in another

This probably isn't the best way to do what I want, but I can't think of anything else to try... NB: I'm using Visual Basic.NET My form has 2 DataGridView controls. One of these is bound to a DataSet, the other isn't visible - at least not until the user selects a uniqueidentifier cell in the 1st grid. When the user makes this selecti...

How to insert,delete,select,update values in datagridview in C# using MYSQL

Hi all, Below is the code to insert value into mysql database, using datagridview. But the selectcommand is working.It is not happening since i get error stating "Column 'username' cannot be null ". This error does not pop up if i use ms access database. Can anyone help me on this. is there any other method to do so. private void b...

C# WinForms BindingList & DataGridView - disallowing EDIT prevents creation of a NEW row? How can I address this?

Hi, Regarding my use of a DataGridView with BindingList, I was to disable editing current rows, but allow adding new rows. The issue I have is that when I disallows edits, this seems to prevent one from adding a new row item, as when you table into the cell for this new row it does not seem to allow editing??? Know how to get around t...

DataGridView column editor empties string properties of a custom column

Hi, I've implemented a custom lookup column, but I'm encountering the damnedest thing with the VS designer. The column has four string properties in addition to the standard column props. Now, if I select the column from the component list in the property grid, then set the properties, everything seems to work fine. However, the moment ...

How do I prevent a DataGridView from autoscrolling when the datasource changes?

I tried this (http://brainof-dave.blogspot.com/2007/08/turning-off-auto-scrolling-in-bound.html) in the "RowChanged" event on the DataTable that is the data source for the DataGridView, but to no avail. Basically, I have a DataGridView with a BindingSource as it's DataSource. The BindingSource's DataSource is a DataView that contains a...

Thread safety advice when using DataGridView and BindingList in C#

I'm writing a class for logging events. My LogClass is implemented as a singleton, and any class in the system can write a log entry. The entries are stored in a List and when a buffer is filled they get dumped to the disk. I'm using a DataGridView to display the contents of the LogClass during execution, therefore I used the BindingLis...

Copy and paste into a DataGridView cell (C#)

I need to be able to copy a name or names from one application (using the normal copy commands) and then be able to double click the text cell in a DataGridView to paste the data into the grid cell. Any ideas on how to accomplish this? I am attempting to minimize keyboard use for this functionality. ...

Fixing FormatException in datagrid view with a checkbox column

I've got a datagrid control bound to BindingList of objects. One of the Properties of the object class is boolean. I have customized that column in the datagridview to be a checkbox type. Things work correctly when the datagridview loads for the rows that have values brought in from the binding list. However, when the "new entry" lin...

C# DataGridView - Transparent Image

I am attempting to populate a DataGridView cell with an image. The image is a 32bit png with Alpha Transparency. I can get this image to display properly in a picturebox or a Listview but in the DataGridView the image loses quality. I have tried setting various parts of the control to transparent but nothing seems to work. I import the...

Editing business objects in Winforms DataGridView

Is possible to edit properties of business object (one property, one column) binded as BindingList to Winforms DataGridView? Or do I have to use DataSet or DataTable? I'm not able to get a cell to edit mode. ...

Need to know the status of a checkbox cell in a DataGridView

I have a C# Windows application that uses a DataGridView with three columns. The first is a textbox that requires no validation. The second and third columns are both checkboxes. I need help with determining if the boxes are checked or not. If they are then I would like to set the background color of the checkbox cell to red. I am using ...

Get Displayed Position of DataGridView Row

The easiest way I see to explain what I need is via example. Suppose I have a DataGridView with 20 rows of data. The DGV is sized to show 10 rows at a time. It is scrolled to show rows 4-13. Row 7 is selected. What I need is a way to get that Row7 is the 4th displayed row. ...

DataGridViewRow not being Garbage Collected

I have a DataGridView being regularly populated via data-bound objects, and the number of rows can potentially become large, say many thousands during a 'logging cycle'. When a new 'logging cycle' begins, the grid is cleared because the underlying datasource is cleared and the process begins again. This is all fine, but because the pre...

Data bind enum properties to grid and display description

This is a similar question to How to bind a custom Enum description to a DataGrid, but in my case I have multiple properties. public enum ExpectationResult { [Description("-")] NoExpectation, [Description("Passed")] Pass, [Description("FAILED")] Fail } public class TestResult { public string TestDescriptio...

Correct way to unbind a BindingSource from a DataGridView

I have a BindingList<> of objects, set to the DataSource of a BindingSource. This is set to the DataSource of a DataGridView. I'm concerned with not causing any potential memory leaks, so wondering if there is a preferred way to unbind these connections when I am finished with the data. I'm thinking of: datagridview.DataSource = null;...

how to programatically edit the cell value of a datagridview in virtual mode?

I have a DataGridView in virtual mode. I only implemented the CellValueNeeded eventhandler as described in http://msdn.microsoft.com/en-us/library/15a31akc.aspx. Implementing the rest of the events only seems needed when you want to be able to edit the cells manually. I would like to programatically edit a DataGridView cell value. I ...

Hierarchical Gridview

Hello everyone. I need to bind hierarchical List object to a Gridview (Hierarchical in windows form). How can this be achieved - any examples ?? Ex: of list object List of CargoMovement => Cargomovents and each CargoMovement has List of Transactions thanks for help ...

How to set datagridview textbox column to multi-line ?.

Hi, I've DGV with my custom List<myClass> as DataSource. I want the "DataGridViewTextBoxColumn" that in this DataGridView to support Multiline property. Could you help me with this please ?. Thank you very much. ...

C# .NET DataGridView enable cell click only to certain columns

Hi all: I have little experience in C#.NET, and below is what I got so far: I created a DataGridView which bound to an ObjectDataSource(a generic list, that is). Although I can make good use of the DataGridView's CellClick event and its corresponding delegate interface(DataGridViewCellEventHandler) to do my business logic well, I am s...

C# - how do I refresh DataGridView after removing rows

Hello, In my code I need to remove rows from the DataGridView after a recurring interval, and so I call the following function when a timer expires: private void removeRows(DataGridView dgv) { foreach (DataGridViewRow row in dgv.Rows) { // if some condition holds dgv.Remove(row); } dgv.R...