datagridview

DataGridView, in-grid edit adding new rows, doing it cleanly?

What is a clean way of handling in-grid edit (specifically: adding new rows) with a DataGridView bound to an in-memory collection? Background: I have a tree structure; for the sake of simplicity, let's assume Directories and Files (my own classes). I use a TreeView to navigate the Directory structure, and populate a DataGridView with th...

Remove row from DataSet if bound table is sorted

I have a DataGridView that is bound to a DataSet and I allow someone to remove a row from the table and I remove the row from the set. My code looks like this: ds.Tables(0).Rows(dgCourseList.SelectedRows(0).Index).Delete() My problem I found is if the grid gets sorted the index of the rows no longer corresponds to the indexes in the D...

ASP.NET Vertical Grid control or Datalist Header template

I'm using a datalist Control to display data in columns and repeat horizontally. I'd like to know if there is a way to create a "header" field that does not repeat for each record, instead it only displays on the left as in the image below. Alternatively, does someone know of a 3rd party "Vertical Grid" control that provides this func...

DataGridView not updating when additional rows are added to the bound DataSource unless I null it out first.

I have a winForms DataGridView bound to a List<MyObjectType>. My problem is that once I do the initial myDataGridView.DataSource = myObjectList; that adding/removing elements from the list is not reflected in the displayed DataGridView even though in the debugger the row count on myDataGridView.DataSource does update. I'm able to for...

Bind Date and Time to seperate columns in DataGridView

I have a DGV bound to a list of objects whose properties include a DateTime value. I'd like to display, and allow editing the Date and Time components in separate columns. How would I do this? ...

how to set a DataGridViewColumn cells to unselectable?

hi. in C# 4.0 (Visual Studio 2010), i have a Windows Form DataGridView that must be multiselect, and it has a specified Column that i don't want its cells to be selectable. what should i do? ...

How to hide button in last("fake") row of Datagridview?

In my dgv I have a DataGridViewButtonColumn which adds a "delete row" button to each row. However, a button also gets created for the "fake" row at the bottom of the dgv, which makes no sense in this context because that row does not correspond to a record yet. What is a good way to hide that button, or at least paint over it? I came ac...

Changing data in datatable and it does not show in Grid

Hi I have a table adapter on a dataset which is linked to a datagrid with a binding source. Now i have a column in my grid that is a checkbox which if clicked i change a value of another column in the grid. So i do it on the cellvaluechanging event of the gridview and then I get the focused datarow in the datatable and change the oth...

Format TimeSpan in DataGridView column

I've seen these questions but both involve methods that aren't available in the CellStyle Format value. I only want to show the hours and minutes portion (16:05); not the seconds as well (16:05:13). I tried forcing the seconds value to zero but still got something like 16:05:00. Short of using a kludge like providing a string or a Dat...

Selectively Disable cells of row in DataBound DataGridView

I need to be able to turn off some cells in a row based on a boolean flag. If the flag is true I everything should be enabled and visible like normal. If the flag is false however I need to have several cells in the row made invisible and readonly. ...

set last row of a datagridview not sortable (always on bottom)

I have a sortable DatagridView with a summary last row containing sum of some columns, i want to keep this summary row always as the last line(bottom) of datagridView. At the moment, when i sort a column of datagridView also the summary row get sorted, i don't want this. I want to keep the last row (summary row) of DatagridView not sort...

Editable Date in DataGridView using dateTimePicker

I have a DateTime column in my winForms DataGridView; currently the field can only be edited by typing the date in manually "2010/09/02", what would be needed to have a DateTimePicker (or equivalent) used as the editor instead? ...

C# Send keystroke to DataGridViewCell

I have a DateTimePicker cell in my DataGridView. I'd like to be able to enter edit mode and drop the calendar when a button is clicked. I'm able to do the first part without difficulty but the second isn't working. If I have a standalone DateTimePicker the SendKeys call does work as expected. //Select the cell and enter edit mode -...

How do I override Microsoft's datagridview to allow back buffering in VB.NET?

My datagridview flickers and is very slow while loading. I reflectored the datgridview from Microsoft and discovered that there is a back buffer property which is not visible from the winForm. How do I set this property? ...

ASP.Net Pre-filled DataGridView

Hi, I have a Table with a foreign key FK. FK takes its values from another table that is already filled. What I want to do is to show a DataGridViw that has already the values of FK filled-in so the user can just type in the remaining values and commit to the database. So for example if FK takes the values 1, 2, 3 and 4. The DataGridVi...

How to make a DataGridView column no-entry in VS2010/C#

Hi, I have a DataGridView which allows me to enter name/value pairs. The names are pre-defined, so the user just needs to enter a value. I have made the name (the first) column read-only so it can't be changed - that's great, but it can still be selected, and indeed, is by default when the form is displayed. Is it possible to make this...

DataGridView columns still automatically created even with AutoGenerateColumns = False

I have a DataGridView and have the AutoGenerateColumns property set to false, but the when I build my project the columns are Auto Generated. I can see the property set to false in the Designer.vb code for the Form. I've had this problem before and I'm not sure how to fix it. Any advise would be greatly appreciated. Thanks. ...

Background colour of DataGridViewCheckboxCell

I have a DataGridView bound to a list of objects, and I'm setting a dynamic cell background colour using the CellFormatting event, as in this answer. This works well for every column except the DataGridViewCheckboxColumn. When I click inside this cell (but outside the checkbox) the cell background changes to the default white. Visually...

Change DataGridViewCell user input handling behavior

I have a winform app with a TimeSpan column that displays the hours/minutes part of a date. When the user enters text it is converted to a TimeSpan using TimeSpan.TryParse(). This works as expected when the user input is "11:00" in setting a value of 11 hours. The problem is that if the use enters "1100" it is parsed as 1100 days whic...

How can I delete specific record from mshflexgrid?

How can I delete specific record from mshflexgrid? For example mshflex grid is showing data from monthly_instal table. Now I want to delete record from this table. I have written code to delete record from that table but its deleting record one by one like 1 2 3 4. I want to delect specific record whatever it is 3 or 4 or 2 or 1. Even I ...