Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
Comment by Seth Spearman on For a .NET winforms datagridview what event do I hook into to change column properties FOR EACH ROW?
Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
Comment by Seth Spearman on For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row
I have a DataGridView that I am binding to a POCO. I have the databinding working fine. However, I have added a combobox column that I want to be different for each row. Specifically, I have a grid of purchased items, some of which have sizes (like Adult XL, Adult L) and other items are not sized (like Car Magnet.)
So essentially what I want to change is the DATA SOURCE for a combobox column in the data grid. Can that be done?
What event can I hook into that would allow me to change properties of certain columns FOR EACH ROW? An acceptable alternative is to change a property when the user clicks or tabs into the row. What event is that?
Seth
EDIT
I need more help with this question. With Triduses help I am SO close but I need a bit more information.
First, per the question, is the CellFormatting event really the best/only event for changing the DataSource for a combo box column. I ask because I am doing something rather resource/data intensive, not merely formatting the cell.
Second, the cellformatting event is being called just by having the mouse hover over the cell. I tried to set the FormattingApplied property inside my if-block and then I check for it in the if- test but that is returning a weird error message. My ideal situation is that I would apply change the data source for the combo box once for each row and then be done with it.
Finally, in order to set the data source of the combobox colunm I have to be able to cast the Cell inside my if block to a type of DataGridViewComboBoxColumn so that I can fill it with rows or set the datasource or something. Here is the code 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 am completely stuck and this task item should have taken an hour and I am 4+ hours in now. BTW, I am also open to resolving this by taking a completely different direction with it (as long as I can be done quickly.)
Seth
How do you create Winform user control that supports multiple items like a listbox
I think I understand the basics of create winforms user control. I can do Add New and select user control and that will give me a design surface and designer file and code-behind file etc. And then I could change it to inherit from something other than UserControl (like listbox or text box).
The thing that is different for me this time is the user control needs to be a list control (like a list box) that can be data-bound and with two data-bindable controls in it (two combo boxes).
I am not sure where to start? Can anybody reference a document or some obvious bit in the tooling that I am missing that will make it quick and easy? Any approaches I can take like extending an existing control. Any gotchas I need to be aware of?
Thanks.
Seth
EDIT
I have decided to take a different approach. I am leaving the question up, though. This is clearly difficulty than I had guessed. WPF is not an option for me unfortunately. Just gonna use a data grid.