datagridview

how to databind datagridview with datatable (C#)

Hi, I want to bind datagridview in windows application with dynamically changed datatable. I have windows form with two textboxes, one for connection string with sql server and the other for sql query string. I just want to display data in datagridview in order to see data. I don't need anything fancy, just to read result of sql query....

Change Column from DataGridView in runtime

Hi, This is probably easy, but I couldn't find an answer anywhere. I'm filling a previously created DataGridView on an ASP.NET Web Form dynamically with a DataTable, but I want to change the name of the columns that appear on that DataGridView, and I simply can't figure out what I'm doing wrong. Below is the code: DataTable dtUsuarios =...

Using a custom formatter in a DataGridView

So, maybe this is a bad design; I don't know. But say I have a DataTable with a column that holds int values; these values are in fact meant to represent some enum type that I have in my project. What I'd like to do is have a DataGridView bound to this table and have the column display the name of the enum rather than the integer value ...

How do I get the selected row data from a data grid view using SelectedRows?

I have a table that I am displaying in a data grid view control. The user selects a single row from the control and presses a button. I need to retrieve the cells from that row and store them as strings. Exactly how do I get the data using the SelectedRow method? I've been working on this for several hours and I'm at the end of my rope...

error in finding control in gridview

I had gridview which on databound I need to hid Image control so I did this code but error apear( grid view dosenot containe defination of RowIndex) when i tried to find control C# Code: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { Img = GridView1.Rows[e.RowIndex].FindControl("Logo") as I...

How could i load a form corresponding to the cell clicked in datagrid

Hi all i will have some data in my datagrid as follows Now if i click on first column on any cell i would like to show a from, and if i click on 2nd row on any cell value i would like to show another form. How can i do this... ...

Copy the contents of a DataGridView in to excel

I found some examples of how to create a excel file from a data grid view, however those just create the file. What I would like to do is have excel open, with a unsaved worksheet, and have the content of the data grid view (including header names) pasted in to the worksheet after pressing a "Export to Excel" button. Basically I want to...

Using + (plus) and - (minus) keyboard keys as incrementors and decrementors in a DataGridView

Hello, On a WinForms application that I am writing in C#, I have a DataGridViewTextBoxColumn with cells holding integer values that I would like the users to be able to increment or decrement using the + and - keys from their keyboards. I've handled the KeyDown event as it is what I use usually to handle Delete keys, etc, but it isn't ...

Use DataGridView for local settings

I need simple way to persist and edit a set of string pairs in my application. I believe that DataGridView with two culmns can help me with viewing and editing, and I was hoping to use application settings instead of database to store data (maybe a DataSet as setting type). I just can't put all that together. Is there a way? ...

Problems loading a DataGridView with a two dimensional arrayList

Hello, I am writing an app where I am loading two DataGridViews from a DB. I have successfully done this using a dataAdapter.Fill(DataSet), but the problem I had was that the data coming from the DB has 10s of thousands of records. It is very slow (too slow, about 7 mins) the first time it is ran. The next time it runs the time is mo...

DataGridViewColumnCollection: count always 0

Hi, I use C# (winform, .net 2.0) to create a DataGridView programmatically to which I connect a BindingSource. Afterwards I want to change the column order (display index property) and the name of the columns (header text property). But when I try to access the column collection of the DataGridView, the debugger always tells me the colu...

How to handle click event in Button Column in Datagridview?

Hello, I am developing a windows application using C#. I am using Datagridview to display data. I have added a button column in that. I want to know how can I handle click event on that button in datagridview. ...

Index of Currently Selected Row in DataGridView

It's that simple. How do I get the index of the currently selected Row of a DataGridView? I don't want the Row object, I want the index (0 .. n). ...

Best way to fill DataGridView with large amount of data

I have a windows form that has two DataGridViews (DGVs) that will hold 25,000+ records and 21 columns each. I have successfully loaded each with the data from the DB using a DataAdapter and then I tried simply filling the GDVs using for loops. Each method took roughly the same amount of time. The first time the data is filled into the...

How to monitor whenever a cell value is changed in DataGridView?

This is a winform C# question. I have a customized DataGridView control inherited from the standard DataGridView class. I want to monitor the case whenever a cell is added to the grid, a cell value is changed in the grid. I have no idea how to do this. The DataBindingCompleted event is helpless in cell/row/column level. The CellValueCh...

Operation did not succeed because the program cannot commit or quit a cell value change

I know it could be asked several times over SO but i still need your help. My grid is on some another form where its events are written. In an another form i have the following code which from whcih i am accssing the grid via forms object and exception is coming. I got the following error message : "Operation did not succeed because the...

C# Perform drag drop between datagridrow to treenode and vice versa

Hi all, I have datatree (kind of folder tree) that each folder represend as node. Next to it, I have datagridview that each row in it represent the treenode content. What I need is to drag and drop node from the treeview to the datagridview and vice versa. Does anyone have an idea or reference of how to do it? ...

binding gridview to objects

My C# app contains a Data Object like this: public class Data { public class a {get;set;} public class b {get;set;} } public class a { public int first {get;set;} } public class b { public int second{get;set;} } I initialize my data when the application starts and my data changes evey time the app is running. I have...

How do I transfer the value of my datagridview row to a group of textbox and databound combo box?

I have a datagridview that contains only 1 row/11 columns every time. How can I transfer the values to a bunch of textboxes and to match the choice in a databound combo box? ...

DataBinding to classes

Possible Duplicate: Binding GridView to Objects My C# app contains a Data Object like this: public class Data { public class a {get;set;} public class b {get;set;} } public class a { public int first {get;set;} } public class b { public int second{get;set;} } I initialize my data when the application starts a...