datagridview

How do you correctly update a databound datagridview from a background thread

I have a custom object that implements INotifyPropertyChanged. I have a collection of these objects where the collection is based on BindingList I have created a binding source for the collection, and set the datasources of the bindingsource and datagridview. Everything works great, except I need to update properties on the custom obje...

DataGridView - Colum Alignment - Center

I have a DataGridView in my application (C# 2.0). Data binding technique used to populate data.I just dock the grid control with parant form.I used to specify the width of the column.I don't want autofill property.I am using custom datagridview. Problem :- I want to align the columns centerly.Just like the print preview page. ...

DataBind to specific records

I have a DataGridView binded to this table: [Users] ID Name -- ---- 11 Qwe 22 Asd Grid is direclty binded to typed dataset table. I have a second table like this: [Records] ID UserID Data -- ------ ---- 67 11 .... 68 11 .... Records.UserID is connected to Users with a foreign key. What I want to do is: when the us...

Deleting rows in a DataGridView

I am currently using a DataGridView coupled with a subform to implement a master/detail setup. The DataGridView only supports row selection and deletion events - editing/adding items is entirely handled in the subform. As such, I maintain a list of entities that I make changes to, while binding the DataGridView to a list of anonymous ty...

Complex databinding to DataGridView header text

Is there a way to complex databind to a column's header text? Or is the only way to manually set the values and listen for change events from the source? For the record, I've tried both MyDataGrid.DataBindings.Add("Columns[<columnIndex>].HeaderText",MySource,"MyProperty"); and MyDataGrid.DataBindings.Add("Columns[\"ColumnName\"].Hea...

Winforms DataGridView Refresh Problem

Hi Guys, I have two Datagridviews in a tab and the datasource of the second grid is based on the row selection in first grid. The problem is I cannot get the grid to refresh after some values have been inserted or updated in the prior tabs. It works fine if I click on the row but it is not working if I select the row programmatically (i...

How can I receive the "scroll box" type scroll events from a DataGridView?

I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On the MSDN documentation page it says I should be able to detect movement of the scroll box by listening for events with types ThumbPosition, ThumbTra...

ScrollBar in DataGridView

I have a winform in vs2008 that contains a DataGridView. The datagrid contains a list with several columns. These are fixed width, exept one that I have set up to take whatever space is left and fill the width of the view. The winform is resizeable in all directions. The issue I am trying to solve is that when I increase the vertical si...

DataGridView/ListView - Display in an Outlook style?

Hello all, I'm used to using Telerik Grids and I'm able to display them in an outlook style, i.e. a picture on the far left, a bold title and a few other lines of text under the main title. Is there a way do this using a standard .Net2.0 Windows control? Either with a cheap control, or the existing datagridview or listview? Basically,...

How to bind a string list to a datagrid?

it looks pretty easy and there must be a way to do it: i have a simple List and i would like it to be displayed in a column in dataGrid. if these were some more complex objects i would know how to set the displayed texts in the columns but i want to display just strings and if i set the list as a datagrid's data source myDataGrid.DataSou...

Empty BindingSource problem

I have a problem with binding data using BindingSource, typed dataset and DataGridView. My problem is: BindingSource, therefore grid, is empty after binding data (bindingSource.Count is 0). I couldn't figure out what I'm doing wrong and I'd be very happy if anyone could help me with this. My application structure is like this: I have two...

How do I format the tooltip used by a DataGridView in virtual mode?

I need to apply formatting - specifically, bold text - to the tooltip used by a DataGridView in virtual mode. I can set the text in the CellToolTipTextNeeded event, but it doesn't support HTML tags; is there some other syntax I should be using? I don't want to have to reimplement tooltip support myself. ...

Allow user to sort columns from a LINQ query in a DataGridView

Hi there I can't quite work out how to allow a DataGridView populated at runtime to sort (when users click on the column headers) where a LINQ from XML query is the DataSource, via a BindingSource. Dim QueryReOrder = From Q In Query _ Where ((0 - Q.Qualifier) / cmbTSStakeValue.Text) <= 0.1 _ ...

DataGridView - DataTable - displaying properties

( .NET 2.0, System.Windows.FormsDataGridView and DataTable ) I have 1 datagrid connected to 1 datatable. That datatable contains 1 column: containing objects of my own type "MyObject". MyObject has a public string property "MyProp". I want to display 1 column in the grid: showing the string values of the property MyProp of the MyObjec...

Adding columns to a DataTable bound to a DataGridView does not update the view

I have a DataTable which is populated from a CSV file then, using a DataGridView the data is edited in memory. As far as I understand the programmatic editing of the data should be done on the DataTable where the user editing is done via. the DataGridView. However when I add columns programmatically to the DataTable, it is not reflected...

Is there a better option than DataGridView for repeating WinForms data?

I'm facing the need to enter "ragged" data in a WinForms application. Some columns are required for some types of entry lines and are not permitted on other entry lines, and the combo box data in later columns needs to vary based on the earlier columns. My question is: is there a better way to handle data that isn't quite as regular as ...

Changing column order in DataTable bound to DataGridView does not reflect in the view

When the application is run, the DataGridView is bound to a DataTable. Later I add more columns to the DataTable programmatically and it is reflected in the underlying data - i.e. the column Ordinals are as they should be. However this is not reflected in the DataGridView. Instead columns are appended onto the originally generated set. ...

VC# 2008: Get Table names from DataTable into ComboList / How to merge tables from 2 MDBs ?

My program that I am writing's purpose arose with this issue: There are two users, each user saves to a .MDB file. One user has half the updated / correct information (the other half is outdated) and the other user has half the information (the other half is outdated). User1: 25% + 25% = 50% current information needed the other 50% is ...

How to get visible row count of DataGridView after BindingSource.Filter?

I have a table with say 1640 items. I set bindingSource.Filter = "some filter query string"; and most of the rows disappear, leaving, say, 400 rows. I'd like to be able to tell the user "Showing 400 of 1640 items" as they click some textboxes which change the filter string and hence which rows are visible in the dataGridView object (m...

How do I get a reference to the underlying object in a bound DataGridViewComboBoxCell?

I don't know if my mind is not working today or if this is actually harder than I think it should be. I've got a DataGridView with a DataGridViewComboBoxColumn bound to a generic IList of CustomObjects. Here's a rough code sample of how I setup the column. DataGridViewComboBoxColumn location = new DataGridViewComboBoxColumn() { N...