datagridview

Programmatically change selection on DatagridView (.NET)

Hi, I'm learning VB.NET. I've a problem with DataGridView component when trying to set the value of the CurrentCell. What i'm trying to do is : I've a DataGridView With values. I want to make a button in my forms and when clicking on it I want to change the selection from the current row to the next. To explain more, by clicking m...

How to disable checking checkbox column in DataGridView - Windows forms?

I have a checkbox column in a DataGridView and I want to validate whether the user can check a checkbox by counting the number of checkboxes they click and deciding then to disable checking. Can someone guide me how to do this effectively?? ...

DataGridViewComboBoxColumn - type of items in the drop down list

I have a DataGridView that has a ComboBox column. I populate this column's list with items of a type Field: DataGridViewComboBoxColumn fieldsColumn = argumentsDataGridView.Columns["field"] as DataGridViewComboBoxColumn; foreach (Field field in SessionData.Fields) fieldsColumn.Items.Add(field); f...

Filtering DataGridView rows in .Net

I have a DataGridView that is displaying a List of objects (not DataSet). Is there an easy way to set a filter, so the DGV will only display rows that match the filter? IList<T> log = ...; dgv.DataSource = log; ...

DataGridView - setting object's displayed value in a column

I bind some collection to a DataGridView. Collection contains KeyValuePair objects where key is a string and value is an object of my class Field. DataGridView displays two columns - one containing the key and the other one containing the value. The value (Field object) is displayed with its ToString() method. But I would like it to be d...

EditingControlShowing events firing multiple times

Hi there. I have a DGV in VB.Net 2008 connected to an Access DB table. The DGV is not Read Only, but is full of read-only columns except for one, which contains a combo box. The combo box allows the user to select an outcome for that particular row, and then the program copies in a pre calculated value into the "Profit" column depending...

Join multiple DataRows into a single DataRow

I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object with a single DataTable that uses the following schema: Id : uint AddressA: string AddressB: string Bytes : uint When I run my application, let's say the DataTable gets filled with the following: 1 192.168.0.1 192.168.0.10 300 2 192.168.0....

Preventing double events in DataGridView

I have a problem that I am not sure how to solve. I have a DataGridView (EditMode = EditProgrammatically). This grid has one checkbox column and one or more textbox columns. The functionality is as following (or should be at least): When you click on a checkbox, the checkbox should be toggled When a row (or many rows) are selected, and...

Suspend Redraw of Windows Form

I have a windows form. It contains several datagridviews on it. At some point, the user can press a button which updates the datagridviews. When they do, they can usually sit and watch the datagridview redraw itself, one row at a time. I'd like for the control to not paint until its "done", that is, I'd like a way to tell the control...

How can I create different cell formats in Winform DataGridView C#

I have a DataGridView that I'm binding to a DataTable. The DataTable is a all numeric values. There is a requirement that every n rows in the DataGridView has text in it, rather than the numeric values (to visually separate sections for the user). I am happy to put this text data in the DataTable or in the DataGridView after binding, ...

Visual Studio adds columns to DataGridView after running program

I have a datagridview that is linked to a three columns in the database, and it's only displaying them (no editing). When I run the program in debug, and exit, when I return to the form in Visual Studio, it has my three columns, plus all the columns in the table it's linked to. If I don't remove these, the next time I run the program, th...

How do you cache a row without raising a "Row provided already belongs to a DataGridView" error?

I want to cache a DataGridView row between 'refreshes' i.e. between a Rows.Clear() and a Columns.Clear(). However it seems that calling the Clear() methods does not unbind the data from the DataGridView instance, An example, public partial class Form1 : Form { public Form1() { InitializeComponent(); ...

How do you update a datagridview in C# every minute

I am working on a project in C# at the moment which is quite simple. I have a status box, two buttons and a dataGridView. When the Form loads the dataGridView is filled correctly. What I would like to do is then update that table every 45 seconds to reflect any changes in the database. I am looking for suggestions on a technique to ...

What's the easiest way to rename the columns of a DataGridView showing a List<T>?

I have a DataGridView, whose DataSource I am setting to a List<T>. T in this case is a class with a property called Foo, whose header I want to show as Foo bar. If it was a datatable, I could just change the query: select Foo as [Foo bar] from Baz But with something like this, where I'm setting the DataGridView's DataSource to a List...

DataGridViewComboBoxColumn - editing the Items

Hi, I am working with a DataGridView and have a column of type DataGridViewComboBox and I have stumbled across a problem. Basically, depending on the value of the cell, i would like to set the .Items to a certain set of strings, but when the value is changed, i would like to change the .Items list. But with this, I will occasionally rem...

Updating multiple selected INofityPropertyChange objects in DataGridView

Hi all I'm working with a DataGridView (Windows Forms) with MultiSelect enabled which is placed in a User Control. I'd like to update all selected rows from outside the User Control by calling a public method that implements the following code: foreach(DataGridViewRow dr in dataGridView.SelectedRows) { MyBusiness business = (MyBusi...

BindingSource's and DataGridView's

Hey Stackers, I have two DataGridView's bound to an underlying DataSource through BindingSources and TableAdapaters. I have two models; strings and tables. Tables -> [id, handle, description] Strings -> [id, handle, table_id] So there's a many-to-one between Tables and Strings. What's the easiest way to make the selection of the "t...

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 that I can only drag from one datagridview to another. Does anyone know how this can be achi...

How to enter a default value to a hidden DataGridView column at runtime?

I'm using a DataGridView to accept certain values at runtime. I've a hidden foreign key column in the DataGridView which should contain a default value while the other columns in the DataGridView are being updated using the Update() method of the OleDbAdapter class. ...

Enable/Disable BindingNavigatorItems based on selected row

I have a winForm with a dataGridView containging members of a team. These members each have an assigned role and other properties that are listed in a column in the grid but for the purpose of what I want to achieve they are irrelevant. I've also added a bindingNavigator with add, edit and delete buttons. What I would like to implement ...