datagridview

Changing image in image button column in a datagridview

Hello, Just wondering if anyone has ever managed to find a way to have a datagridview image button column in a template field which display different images on different rows depending on some data element in the row. Our application needs to display a series of fees charged against an account column which will be either less then 500,...

Why so many ColumnDisplayIndexChanged events when DataBinding a DataGridView ?

Hi, Can anyone explain to me how the ColumnDisplayIndex property is being used when a DataGridView is data bound ? The reason I ask is this. I have two grids, one above the other. I would like the user to be able to rearrange the order of the columns in the upper grid, and (via the ColumnDisplayIndexChanged event) reflect those reorder...

C# Winforms visual inheritance problem with DataGridView.

From here I have created a BaseForm, then set all its BaseForm.Designer.cs private members to protected. Then has had a visually inherited/derived Form. Now I am able to re-size or modify all the controls in the derived Form in design-time except the DataGridView. I am finding the DataGridView as locked in the derived Form, even though ...

VB.NET DataGridView "An item with the same key has already been added." while using a unique index

VB.NET 2010, .NET 4 Hello, I've looked around and can't seem to find a solution to my problem. I have an EventLog object which inherits DataGridView and has a public variable EventList which is a List(Of EventLogItem). EventLogItem has seven properties which describe the event, including Index which is set to EventList.Count each tim...

Filter rows in DataGridView bound to object collection

Hi, I need to filter what items from a collection object that I want to show in a DataGridView. It may be; ObjectModel.Collection, a BindingList or simply a List. I may use a BindingSource between the object and the DataGridView if that's an advantage. What different options do I have for filtering, while still maintaining two-way bin...

Unable to edit any columns in my C# DataGridView - would anyone know why?

Hi folks, I'm trying to enabled editing for a number of columns in my DataGridView. Now, before anyone suggestions I should read the MSDN article: How to: Specify the Edit Mode for the Windows Forms DataGridView Control, I already have. In summary (and I quote): The underlying data source supports editing. The DataGridView control is...

Group by in Datagrid View

Hi, i have a scenario where i have to group the PinCode by city name like one city can have many pincode. I have to do this in winform in datagrid. How can i do this so in datagrid i can see the + and - on before city. I thing it can be done by nested grid. please, help. Column A | Column B | Column C Country Zip Co...

How to determine which DataRow is bound to a DataGridViewRow

Hi all. When I use a DataTable as a DataGridView's DataSource, I often have to find which row(s) a user has selected and read specific values from the DataTable (not the DataGridView) I wanted to know if there is any reliable way of determining which DataRow a DataGridViewRow is bound to especially when the user has sorted the DataGrid...

How to fill different ComboBoxes in a DataGridView control with C#?

I have a datagridview with 3 comboboxes. When in combobox 1 (=Rownumber = 1) AA is selected then at runtime combobox2 has to be filed with some value. This value is comming from a DataTable. When some value is selected in combobox2 (Also RowNumber = 1), then at runtime combobox3 (also RowNumber = 1) has to be filled with some value also...

LINQ to XML and DataGridView

Hi I’m trying to use a DataGridView for the first time and with LINQ. Here’s what I’m trying to do: I want to use it (although it doesn’t have to the DataGridView ) to read and display the contents of an XML file (this bit is working code below) but I want to have an add row button on the form or in the DataGridView that takes the conte...

Inserting Selected Row onto SQL Server Database from GridView

protected void Authorise(object sender, EventArgs e) { CheckBox chk; foreach (GridViewRow rowItem in GridView1.Rows) { // gets the Debit Reference number for each row checked string type = GridView1.DataKeys[rowItem.RowIndex].Values[0].ToString(); // gets the Debit E...

display a winform by double click a cell in a DataGridView

SoS help I'm lost with BindingSource Details user :QSIDevelope posted on Wednesday, February 04, 2009 7:29 AM I found a code to display a winform by double click a cell in a DataGridView I can not find I built this piece of code StageDetail class not run ///// public struct StageDetail { private bool _xlogico; private string _x...

Apply and validate a bound DataGridViewComboBoxCell directly upon selection change

I have a windows forms DataGridView that contains some DataGridViewComboBoxCells that are bound to a source collection using DataSource, DisplayMember and ValueMember properties. Currently the the combobox cell commits the changes (i.e. DataGridView.CellValueChanged is raised) only after I click on another cell and the combobox cell lose...

Two datagridviews in one windows form = not possible to save data to the second datagridview

I create a winform I´m adding a datagridview by dragging a table from data sources the result: I´ve got a winform with a datagridview and a bindingnavigator I´m adding a second datagridview to the same winform by dragging another table from data sources the result: same as bullet 3, but now with two datagridviews; a second bindingnaviga...

How to bind an array of DataRows to a DataGridView

I'd like to partition my search results (which is in a DataTable) into groups of say 100 so the user navigates through them a chunk at a time. I thought I could bind an array of DataRows to a DataGridView as the DataSource but it just does not work. This is the code I tried DataGridView.DataSource = (From r In DataTable.Rows Skip 200 T...

ScrollBars of DataGridview will be Crash when the height of all rows exceed the vision height of DataGridview

As the title say, DataGridview.ScrollBars = Vertical; Assume the vision of DataGridview can contain 4 rows, if the row comes to 6, it has a Vertical ScrollBar. But if click the ScrollBar, the program will crash. If we set the DataGridview.ScrollBars = None, no problem will happen. public partial class visitorLeave : Form { publi...

How to format DateTime columns in DataGridView?

Hello, I'm using a DataGridView with object data binding to display information about logging entities in a system, retrieved via SOAP from a remote service. One of the columns is called "Last action" and means the last time the entity logged a message. It is a System.DateTime value. When I read the SOAP response (example below), he time...

How to get cell value change when closing form?

Hi, I have a form with a DataGridView on it. In this DataGridView there is a DataGridViewComboBoxColumn. When changing the value of a cell of this DataGridViewComboBoxColumn, the CellValueChanged-event is only fired when leaving the cell (for example, if I click into another cell). The event is not fired when I change the value and the...

c# datagridview help

Hi, I have a form showing a gridview. The data is bound dynamically, depending on several options that the user clicks on. The populating data works fine (bound from dynamically created datasets). The problem lies, when I want to switch between displaying data whereby the tables/datasets contain different layouts. The gridview keeps...

C# - 2 problems - referencing a cell in DataGridView_RowsAdded causes nullreference error; Cant update database with DataGridView data...

Hey, I just started writing a customer application in C#, using Visual Studio design mode for most of it. Bear in mind I only started learning C# yesterday - so if I am making any stupid mistakes then please say so. What I have so far A database; A DataSet which links to the Customer and Agent tables; A BindingSource which binds to t...