datagridview

How to save position after reload DataGridView

this is my code: private void getData(string selectCommand) { string connectionString = @"Server=localhost;User=SYSDBA;Password=masterkey;Database=C:\data\test.fdb"; dataAdapter = new FbDataAdapter(selectCommand, connectionString); DataTable data = new DataTable(); dataAdapter.Fill(data); ...

DataGridView avoiding adding new columns

Why, this code create 2 the same columns in grid (Color and Color). How to inputs data color from collection in column which existing before set datasource ?? public Form1() { InitializeComponent(); DataGridViewTextBoxColumn ds = new DataGridViewTextBoxColumn(); ds.Name = "Color"; ...

how to get data from a datagridview and insert into database?

hi guys i ve a datagrid and wen a button s clicked i want the values from the datadrid to the database.. thanx in advance ...

How do you use data binding in C# winforms development ?

Recently I use data binding to speed up my development of C# winforms application. But I found that data binding is just useful when the control is Textbox or textare and text kind of controls. If things come to be radio button, image control or datagridview, it's hard for me to use data binding. For example, it's hard for me to...

DataGridView that always has one row selected

I'm using a DGV to show a list of images with text captions as a picklist. Their must always be a one and only one selection made in the list. I can't find a way to prevent the user from clearing the selection with a control-click on the selected row. Is there a property in the designer I'm missing that could do this? If I have to ...

Controlling the Text of a DataGridViewButtonColumn in a Databound DataGridView

I can add a DataGridViewButtonColumn to an existing DataGridView that is databound to a BindingList of my class. (There doesn't seem to be a way to have a DataGridViewButtonColumn auto generated - you apparently have to add manually) Is there a way to control the text that is displayed on the buttons by having it bound to a public prop...

I want to get the particular column value of the current row of the datagrid view into text box of another form. How can I do it. I am using c sharp

I want to pass the column value of the current row of the datagridview. I have a button on one column in the datagridview. When I click on the button , another form opens up. I have a text box on the another form. So I want to get the column value of the current row on the text box of another form. I am using c sharp. Any help is apprec...

How to roll back changes in gridview in case of incorrect input...

Hi, I have a DataGridView that is bound to a list of object. It has some columns that the user can edit. There are certain inputs that are not allowed for a row as a whole. How can I roll back if the user enters invalid inputs in some cell. I tried using the RowValidating event handler but it was not called after cell value has been ch...

Format of DataGridView value

I have a DataGridView which is filling from Table in SQL Server Database. One of it's columns is "price". Type of column in DGV is automatically sets as Decimal. In some cases I need to write in cells of this column text like "none", instead of price. How can I do it? DGV.Item("price", 0).Value = "none" doesn't work, because of dec...

How to wait for the user to select one of the datagridview rows?

I have a datagridview populated with some Names, I want to perform a check of all the Name in another database with the Names in datagridview and add the Surnames to the adjacent cell when a match is found, this I am achieving by string compare method. My Problem is that due to typing inconsistencies & at times with two people having sa...

fix a columns width when a list is bound to a datagridview

I have a list that I have bound to a datagridview. I want the first column to be a fixed size. The data is bound to the dataGridView and I can't seem to find a way to access an individual colums properties. if I try myDatagridview.colums[0] I get an index out of bounds, since it says the columns count is 0. private DataGridView se...

DataGridView formatting

I have a DGV with columns "code" and "name". Depends of lenght of a code I want to add tabulation to the "name" cells, to show structure of a data. Like that in this picture: How is it better to do? I think there is a better way then just loop for all rows and add spaces in front of names, right? ...

datagridview perfomance loading data

Hi, I've got collection of 50k records, and i get it in one second, but loading it to database take about 10 secunds. How to increase loading data? Everything what i make now is: dgvCars.DataSource=cars; ...

How to update the column of datagridview from the text contents of textbox in c# Windows form

I have a datagridview with contents from a table. In that I have a column for Remarks which will be 1-2 lines. When I click on the remarks column, I want to open another form that contains the text box. I have linked the text box with the table using the table adapter. Now when I close the form with the text box, I want to show that in t...

Visual marker when moving rows on DataGridView

Users drag rows up and down in my DataGridView. I have the dragging logic down-pat, but I'd like there to be a dark marker indicating where the row will be placed after I let go of the mouse. Example from Microsoft Access; I want to drag rows instead of columns Does anyone know how I'd go about doing this? Is this built-in, or would...

How do I achieve copy/paste behavior both ways between Excel and a DataGridView component?

How do I accomplish being able to paste data from Excel into a DataGridView and vice versa? ...

How to edit cell of type Linkcolumn in a gridview

I have a gridview control having 4 columns. one of the column is of type linkcolumn. user has to enters data for each column. How can we edit link column cell. if i click on this cell nothing happen.i set its readonly to false also. ...

How do I handle editing of custom types in a C# datagridview?

I have a datagridview in which one column contains a custom class, which I have set using: dgvPeriods.Columns[1].ValueType = typeof(ExDateTime); It is rigged up to display correctly by handling the CellFormatting event, but I'm unsure what event to handle for cell editing. In the absence of doing anything I get a FormatException as th...

DataGridView Button Column Use like Edit ?

I have A DataGridView Button Column , I want - when we click Button column then we Edit Current Rows ...

How can I make datagridview can only select the cells in the same column at a time?

I am using winforms to develop my application. And I set my datagridview control's selectionmode to "CellSelect", and this allow the user to select as many cells as he want which spread over several columns; but I want to constraint my user can only select cells in single column at a time, and there isn't any such kind of selectionmode ...