I have a DataGridView that I bind to POCO. Work with data works for me. However, I have added a combobox column that I want to be different for each row. In particular, I have a grid of purchased items, some of which have dimensions (for example, Adult XL, Adult L), while other items do not have a size (for example, βMagnet for carsβ).
Therefore, in essence, I want to change the DATA SOURCE for the combobox column in the data grid. It can be done?
In what event can I connect, which will allow me to change the properties of certain columns for EACH ROW? A valid alternative is to change the property when the user clicks or inserts tabs in a row. What is this event?
Set
EDIT
I need more help with this issue. With Triduses, I'm so close, but I need a little more information.
First, when asked if the CellFormatting event is really the best / only event to change the DataSource for the combo column. I ask because I am doing something quite resource intensive, not just formatting the cell.
Secondly, a cellular formatting event is triggered only by hovering over a cell. I tried setting the FormattingApplied property inside if-block and then checking it in if-test , but this returns a strange error message. My ideal situation is that I would apply a change to the data source for the combo box once for each row, and then execute it.
Finally, in order to set the data source in colombm combobox, I have to be able to block Cell inside my if block of type DataGridViewComboBoxColumn so that I can fill it with rows or set a data source or something like that. Here is the code that I have right now.
Private Sub ProductsDataGrid_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles ProductsDataGrid.CellFormatting If e.ColumnIndex = ProductsDataGrid.Columns("SizeDGColumn").Index Then ' AndAlso Not e.FormattingApplied Then Dim product As LeagueOrderProductInfo = DirectCast(ProductsDataGrid.Rows(e.RowIndex).DataBoundItem, LeagueOrderProductInfo) Dim sizes As LeagueOrderProductSizeList = product.ProductSizes sizes.RemoveSizeFromList(_parentOrderDetail.SizeID) 'WHAT DO I DO HERE TO FILL THE COMBOBOX COLUMN WITH THE sizes collection. End If End Sub
Please, help. I was completely stuck, and this task subject had to go an hour, and now I am 4 hours. By the way, I can also resolve this by taking a completely different direction with him (so far I can do it quickly).
Set