datagridview

Visual Basic, How do I read each row in a datagrid?

Hi all, I have a datagrid called DataGridView1, column A contains a name, column B contains a path to a file. How do I run some code for each row? What is the correct terminology for traversing a datagrid in this way? Example of what I need: For each row in DataGridView1 MessageBox.Show DataGridView1.ColumnA.text & "," & DataGridView...

How do I handle drag-and-drop in the designer?

I've created a control, DataGridViewContainer, that fakes partial-line scrolling in a DataGridView - basically it's a panel and a scrollbar and a few event handlers. I'd like to be able to use DataGridViewContainer at design time, dragging a DataGridView onto it to set its .DataGridView property to the dragged control. How do I handle ...

Select ListIndex instead of Object for selected entry in DataGridViewComboBoxCell

Hi, I have a DataGridViewComboBoxCell, whose DataSource is a List. When an item is selected from the list, I wish to store the index of the item, not the item itself, in order that I can switch DataSources and still display a relating list entry. e.g. I have a list of months (January-December). I want to select "April" and store "3" in ...

Can a bound DataGridView use text cell for boolean values?

I have a DGV bound to a list of objects. This works fine except that one of the object properties is boolean and therefore displays as a checkbox but I would prefer a simple yes/no text field instead. I've considered adding an additional column and populating with the appropriate string based on the boolean value but this seems a little ...

Visual Basic, Why does this code result add an extra row to my datagrid?

Why does the code below result in 3 rows in my datagrid when there is only 2 rows in my CSV file? I end up with 2 populated rows and one empty row. The CSV file only contains 2 lines. I suspect the logic of the code below. Do While Read() row = New DataGridViewRow() For Index = 0 To FieldCount - 1 cell = New DataGridView...

How to use DataGridViewButtonColumn in non bound DataGridView

Using WinForms, C# .Net 2.0 I'm adding rows to a non bound DataGridView. I would like to have a DataGridViewButtonColumn in one of the columns that deletes that row when clicked. When I try to add a Click event to the DataGridViewButtonColumn, there does not appear to be a definition for Click. Can anyone point me to a MSDN article o...

How can I get a datagridview to display a list<int>/list(of integer)?

seems simple enough, I want to take a generics list of integers and display them on a datagridview. google comes back with plenty of results on displaying custom classes in a datagridview, but not a list of int. when I just submit the list as the datasource, nothing shows. I tried using dim _CheckIns as new list(of integer) _checkins....

How to set column header text for spesific column in Datagridview C#

Hi, How to set column header text for specific column in Datagridview C# ...

C#: How to adjust the value the user entered in DataGridView?

I have a databound DataGridView. The data source is a typed data set with a table containing two DateTime columns (BeginTimeStamp and EndTimeStamp). I read and write the data to an SQL Server 2005 database using the typed data set's Update command. The user must enter a date into each of the two columns, which I enforce using the CellVa...

DataGridViewRow

I am having a DataGridView in which user can add delete and insert rows manually. Initialy DataGridView fetches data from the database and populate the grid. I have to figure out all the rows that user manually added ( which are not fetched from the database) Is there any flag to check if the Current row is newly added row while iterati...

Populating Values For DataGridView from DataBase based on the condition

Hi All, I am creating an application where in I want to display the rows in DataGridView based on the values entered by the user in the textbox. For Eg. If the User enters the BookName in the textbox all the details regarding that book should be displayed in a DataGridView. I have used the following codings: SqlConnection...

utility class vs subclassing .net controls

I want to reuse some code I wrote to add some functionality to a datagridview. I want the default datagridview properties and events to be exposed, so I didn't want to create a new custom component. so I tried writing a subclass, which works fine. but it also occurred to me that I could write a standalone utility class that takes a datag...

DataGridView Master-Detail for DTOs?

In my Windows Forms app, I two DataGridViews that represent a Master-Detail relationship. The datasource for each is a Data Transfer Object, represented as an IList(of T) -- so DataRelation is out. What is the best way to drive the master-detail grids? Is there a built-in way to do this in .NET or do I have to write my own rebind when...

DataGridView row repositioning

Is there a simple way to swap the position of two rows in an unbound DataGridView? I am using it to display an ordered list, where I want the up/down arrow keys to shuffle a row up and down the grid, but I can't see any way to reposition a row within the grid without completely repopulating it, which seems excessive. The Index value ...

Binding to interface and displaying properties in base interface

This question (along with its answer) explains why you can't easily bind a DataGridView to an interface type and get columns for properties inherited from a base interface. The suggested solution is to implement a custom TypeConverter. My attempt is below. However, creating a DataSource and DataGridView bound to ICamel still only resul...

Preventing column auto sort after editing a bound DataGridView.

Hi I've got a DataGridView that has a DataTable as it's Datasource. Whenever I sort a column and then edit a cell, after editing the column, the column autosorts so the recently edited cell is no longer in the viewable area. Is there any way to prevent this auto sort from happening and only sort when I click on the columns? Many thanks ...

Why does my datagridviewcolumn not accept changes at this point?

I'm bringing down a strongly typed dataset table into a datagridview. then adding a column of combo boxes to let the foreign keys be selected by name instead of ID. Perhaps there's an easier way to do this. can I transform the typeID column into a comboboxcolumn while still being able to cast the datasource back to my strongly typed da...

Saving settings for "AllowUserToOrderColumns" of my DataGridView

Hello. Is there a way to make my program remember the way columns are re-ordered so when the application is re-opened, it orders them the same way as it was when I closed the form. I can't find any properties for this. Thanks. ...

DataGridViewComboBoxCell takes several clicks to bring up menu for another cell. Advice on speeding up the process?

Hi, In order to bring up the menu for a DataGridViewComboBoxCell, I first have to click: 1) the row of the cell I want to edit 2) within the cell I want to edit 3) the I want to edit again, in order to open the ComboBox for the cell. If another cell is already selected, the first click will close the already-active ComboBox, then 3 more...

Group by in Winforms/webforms DataGrid

I'd like to implement the group by features for the default grid as it's available for the commercial grid like devexpress/infragistics et al, if you want a sample, see the 2nd image on http://www.devexpress.com/Products/NET/Controls/WinForms/Grid/dataoperations.xml I'd think there's some pattern or better yet some opensource/free grid ...