Borix Posted June 2, 2008 Posted June 2, 2008 Hi all, I am using the DataGridView_CellFormatting() event to format the values of the programmatically added values in a datagridview. Now, while everything else works, my stored procedure returns a column of BIT type. Automatically, it appears, the datagridview transforms that particular column's cells into DataGridViewCheckBoxCell's. However, in the CellFormatting event, I want some text to appear (like "Yes" or "No") instead of a checkbox. When I executed the following code, a casting error appears. So, how can I convert this checkbox column into a textbox column programmatically? [color="Blue"] Private Sub[/color] dgvAnkand_CellFormatting(ByVal sender [color="Blue"]As[/color] Object, ByVal e [color="Blue"]As[/color] System.Windows.Forms.DataGridViewCellFormattingEventArgs) [color="Blue"]Handles [/color]dgvAnkand.CellFormatting ' 23 and 24 are the indices of the two BIT columns [color="Blue"]If[/color] (e.ColumnIndex = 23 [color="Blue"]OrElse [/color]e.ColumnIndex = 24) _ [color="Blue"]AndAlso [/color]e.RowIndex <> dgvAnkand.NewRowIndex [color="Blue"]Then[/color] ' The following returns a casting error: Boolean cannot be converted ' to string, etc... e.Value = IIf(e.Value, "Yes", "No") [color="Blue"]End If[/color] [color="Blue"]End Sub[/color] Thanks in advance. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.