I am inserting a column in a DataGridView programmatically (i.e., not bound to any data tables/databases) as follows:
int lastIndex = m_DGV.Columns.Count - 1; // Count = 4 in this case
DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)m_DGV.Columns[lastIndex];
m_DGV.Columns.RemoveAt(lastIndex);
m_DGV.Columns.Insert(insertIndex...
I've made a custom DataGridViewCell that displays a custom control instead of the cell; but if the DataGridView uses shared rows, then the custom control instance is also shared, so you get strange behaviour (for example, hovering over buttons highlights all the buttons). Also, I can't access the DataGridViewCell.Selected property, so I...
How do you access the items collection of a combo box in a specific row in a DataGridView?
I'm populating the combo as follows:
Dim VATCombo As New DataGridViewComboBoxColumn
With VATCombo
.HeaderText = "VAT Rate"
.Name = .HeaderText
Dim VATCol As New JCVATRateCollec...
I have a DataGridView control in a TabPage, and I listen for the SelectionChanged event. When the TabPage is selected, the DataGridView selects the first row and fires the SelectionChanged event. How can I stop it from automatically selecting a row?
...
I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to drop down (open) this DataGridViewComboBoxColumn manually, let's say after a button is clicked.
The reason I need this is I have set SelectionMode to FullRowSelect and I need to click 2-3 times to open the combo box. I want to click on the co...
I have a DataGridView in a VB.NET app that I have limited to cell selection only. The control has two columns, the first is not editable, the second is editable. I have a ContextMenuStrip that provides some additional functionality and I am able to make it appear when an editable cell receives a right click and is not in edit mode. Based...
We had a performance issue with DataGridViews where the redraw was horridly slow and found the solution Here to create a derived type and enable double buffering on the control.
(Derived type is necessary since the DoubleBuffered property is protected)
It doesn't seem like there's any drawback to having the DoubleBuffered property set t...
Is there a way to "stream" a set of results (eg. a DataTable) from a BackgroundWorker to a DataGridView. What I want to do is to query data, and fill the results in a DataGridView as they come (like query grid results in SQL Server Management Studio). My first thought was to use a BackgroundWorker (to avoid the UI freeze effect), but the...
whats the best way to refresh a DataGridView when you update the base data source?
i'm updating the datasource frequently and wanted to display the outcome to the user as it happens.
i've got something like this made (and it works), but null'ing out the DataGridView.DataSource doesnt seem like the right way.
List<ItemState> itemStates...
Hi all,
I'm doing .NET 3.5 programming in VB for a class. I have a .mdb database with 3 related tables, and a table adapter with some queries on it that look like this:
SELECT PropertyID, Street, Unit, City, Zip, Type, Bedrooms, Bathrooms, Area, MonthlyRent
FROM tblProperties
Then in a form i have a DataGridView. What i w...
What's the best practise way to handle a primary key in an unbound datagrid view combo-box column?
I want to display a meaningful value but store only the primary key (much like Access combo-boxes). I achieve this with a regular combo-box by adding an object with two properties into the items collection rather than a plain string. I th...
My app has a DataGridView object and a List of type MousePos. MousePos is a custom class that holds mouse X,Y coordinates (of type "Point") and a running count of this position. I have a thread (System.Timers.Timer) that raises an event once every second, checks the mouse position, adds and/or updates the count of the mouse position on t...
Ok, so I'm binding a DataGridView to a BindingSource in a background thread while a little, "Please Wait" model window keeps the user entertained. No problem.
However, I need to change some of the rows background colors based on the row's databounditem type. Like this:
for (int i = 0; i < dgItemMaster.Rows.Count; i++)
{
if (dgItemM...
Hi,
I am creating an application which displays some messages and its directions in the DataGridView. I would like to replace some columns content with pictures. For example I would like to replace number 0 which represents the incoming call with a green arrow (some .jpg image).
Does anyone know how this could be achieved?
Thanks!
...
Hi,
I am trying to set the background color of a DataGridView row to red. I tried with the following line:
dgvActiveCalls.Rows[1].DefaultCellStyle.BackColor = Color.Red;
but it doesn't work. Then just to see if something is wrong with update I tried to paint the column instead of row:
dgvActiveCalls.Columns[1].DefaultCellStyle.BackCo...
Hi there
I am trying to get the DataGridView to render the "insert new row" row as the first row in the grid instead of the last row. How do I go about doing that, is it even possible in the control?
Regards, Egil.
...
In a DataGridView bound to a DataView, where cells in a column will contain one of two images from an ImageList (e.g. a green 'online' image or a red 'offline' image), how can you sum the number of occurences of each image when iterating through the DataGridView's rows?
The Value and FormattedValue properties of DataGridViewImageCell re...
How do I link an editable datagridview to an XML file in a winforms project?
...
Does anyone know how I can disable the System Context Menu when a user right clicks in a DataGridViewTextBoxCell? I have tried to override the WndProc at the DataGridView level (as there is no WndProc to override on the Cell level), but nothing seems to work. Any help would be greatly appreciated.
The following is what I use to achie...
I have a DataGrid with 5 template columns,
However when I try and add some dynamically created controls into the grid, it fails, as there are no rows.
-Can i add a blank row in and use that? and how?
-Or any other way?
...