datagridview

Enabling and Disabling a cell in a Datagridview

Hi I am using Datagridview contyrol for populating the data. I need to enable some data and disable some data based on some values dynamically !! Can anyone tell me the code to do it ? ...

DataGridView column order does not seem to work

I have a DataGridView bound to a list of business objects: Dim template As New IncidentTemplate Dim temps As List(Of IncidentTemplate) = template.LoadAll Dim bs As New BindingSource If Not temps Is Nothing Then bs.DataSource = temps Me.dgvTemplates.DataSource = bs End If I then add an unbound button column and make some of th...

Correct way to have a DataGridView visually reflect changes in its DataSource

Say a DataGridView has its DataSource property set to a DataView instance. DataGridView dgv; DataTable dt; // ... dt gets populated. DataView dv = dt.DefaultView; dgv.DataSource = dv; // ... dt gets modified // The DataGridView needs to update to show these changes visually // What goes here? I know you could set dgv.DataSource t...

How to bound a DataGridViewComboBoxColumn to a object?

I'm trying to bound a DataGridViewComboBoxColumn to an instance of Foo, but when i set a value on the grid i got a ArgumentException telling me that i can not convert from String to Foo. var data = (from item in someTable select new { Foo = item.foo, Bar = item.Bar }).ToList(); grid.DataSource = data; column.DataPropertyName...

Disbale DataGridViewRow unselect when CTRL is pressed

If the CTRL key is pressed and you click a selected DataGridViewRow the row is unselected. How can I stop this? ...

VB.NET: Getting DataGridView to Populate from Stored Procedure

Hi, I was just handed a VB.NET prototyping effort, and I'm not very experienced with VB.NET. I had to create a stored procedure which returns a self-referential table in order. Once, I completed that I wanted to get a DataGridView to show the results. Previously, my team has been doing a lot of this via the GUI designer of VB.NET so I...

how do I display time in a windows forms dataGridView bound to a datatable

hello, I fill a datatable from using the fill method from a SqlDataAdapter. I then bind it to a DataGridView using the DataSource property dataGridView1.DataSource = mydataTable; I would like the DateTime columms to also show the seconds. what do I need to change to default to shoing the seconds. Thanks ...

When do a DataGridView's cells' bounds and visibility change? What about rows?

I'm writing a cell and row class that will allow users to host controls inside DataGridViewCells and DataGridViewRows. I'm doing it by adding the control to the DataGridView's control collection and showing or hiding it at the appropriate position onscreen to overlay the cell or row. I need to find out when the cell or row's bounds or ...

How do I move a tooltip?

I'm using the CellToolTipTextNeeded event of a DataGridView, and the tooltip is being shown under the mouse. I can get the ToolTip object out via reflection, but I don't have any control over where it's positioned since I'm not the one calling Show(). How do I move a tooltip? ...

Porting a VB6 application with msflexgrid to vb.Net

I am porting a vb6 application to VB.net. One of the key forms has a large msflexgrid on it - about a 1000 columns and 50 rows. It has 2 header rows - the first header row has merged cells to form a main header and the second row has sub headings. There is no requirement for any data entry and it's unbound. The code does the work in deci...

How do I find out whether a control is currently invalidating?

I'm writing a custom DataGridView cell class that hosts a control. I'm listening to the Invalidated event to know whether I should reposition and repaint the cell, but I'm getting loops because repositioning the cell can invalidate other hosted cells, which then invalidate the first one, and so on. I don't want to use a static member t...

Can I have an 'offscreen' control?

I'm trying to create a DataGridView cell class which hosts a control (all the time, not just while editing). So far, my approach has been to add the control to the grid and try to synchronise its position with that of the cell. Would it be possible instead to keep the cell offscreen, route mouse and keyboard events to it, and paint it ...

DataGridViewComboBoxCell Binding - "value is not valid"

I'm trying to bind separate ComboBox cells within a DataGridView to a custom class, and keep getting a "DataGridViewComboBoxCell value is not valid" error. I'm currently assigning the data source for the cell to an IList from a Dictionary I've got. Upon setting the data source however, the index for the ComboBoxCell isn't set, so it has...

Databound DataGridView Empty Despite Full DataSource

I have a base form class that contains a method that returns a DataTable: protected DataTable GetTableData(string sql, OracleConnection connection) { DataTable table = null; OracleDataAdapter adapter = null; try { table = new DataTable(); adapter = new OracleDataAdapter(sql, connection); table.Locale = System.Global...

optimize updates to DataTable bound to DataGridView

I have a Form in my application that displays some data. When I first show the Form, I load some data into a DataTable then bind the DataTable to a DataGridView. I also start an asynchronous method that executes some slower database queries. When these slow queries complete, I need to update a few hundred rows in the DataTable, filling i...

Reference Access database dataset.designer file in WPF?

Hey, I've included an MS Access database in my WPF VB app, and I'm trying to link the data to an XCEED Datagrid. I have the following code in my testerDataSet.Designer.vb file which I assume is the funcion I should be referencing Public ReadOnly Property Contact() As ContactDataTable Get Return Me.tableContact End Get En...

In C#, how to add Intellisense to DataGridView cells?

I would expect this would be a common need. Can anyone help or point me to a page that explains how to do this? ...

DataGridView shifts row on update

Sometimes when I update a row in a DataGridView a shift occurs in the row like this: Look at the row in the middle and notice how three of the columns are drawn incorrectly. Once this happens, even a refresh doesn't seem to fix the problem. The problem does go away when any of the data in the row gets changed. Any ideas? ...

How to export datagridview to excel using vb.net?

good day, i have a datagridview in vb.net that is filled up from the database. I've researched and i found out that there is no built in support to print directly from datagridview. I don't want to use crystal report co'z im not familiar with it. I'm planning to export it to excel to enable me to generate report from the datagridview. ...

How to update datagridview

I am working in c# project, i need to update datagridview control after inserting a new record. When i am doing this, the gridview keeps its old values also, what should i do to show only updated records ...