Bound DataGridView with unbound text box column
-
The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table. I have my grid displaying nicely, with the empty text box column. I have the values to insert into the grid. But when do I do it? With which event handler? I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called. EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.
-
The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table. I have my grid displaying nicely, with the empty text box column. I have the values to insert into the grid. But when do I do it? With which event handler? I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called. EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.
Nigel Mackay wrote:
With which event handler?
Depends on "how" you'd want to do so. One option would be the CellFormatting[^] event. Get's called whenever the value of a cell is needed. Check if the cell is in the last column, and if so, fetch the value - otherwise, display the default.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Nigel Mackay wrote:
With which event handler?
Depends on "how" you'd want to do so. One option would be the CellFormatting[^] event. Get's called whenever the value of a cell is needed. Check if the cell is in the last column, and if so, fetch the value - otherwise, display the default.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Yes, that would work. In fact it rings a bell from many years ago, along with CellValueNeeded and CellValuePushed. Because I only have 2 bound and 1 unbound column and the grid is Read Only I created the grid manually. That way I can populate the grid while it is being built.