I have a working VB6 program with a Datagrid bound to an ADO Recordset. I am using the Format and UnFormat events of a StdDataFormat object to apply special formatting to the Columns of the Datagrid, leaving the values in the database unformatted. So far, so good.
My problem is that I want to be able to determine, from within the Format/UnFormat event subroutines, which column of the Datagrid is being processed (there is only one StdDataFormat object shared by all columns that need the special formatting). The Format/Unformat subroutines have a single parameter, the DataValue object. The DataValue object (a StdFormat object) has two properties, Value and TargetObject. The Value works fine, but the TargetObject, which should give me exactly what I am looking for, is set to Nothing, when I would have expected that it would be set to a Datagrid.Column object.
I stress that the StdDataFormat Format/UnFormat mechanism is working correctly, except that TargetObject is Nothing, preventing me from discriminating between the Columns of the Datagrid.
As an experiment, I wrote a similar program using a Textbox in place of a Datagrid, and in this case the TargetObject was set to the Textbox as expected.
Does anyone out there have experience with using TargetObject with a Datagrid? Is it possible that the TargetObject is not being set because the Datagrid requires complex binding (a field is bound to each column)?
My problem is that I want to be able to determine, from within the Format/UnFormat event subroutines, which column of the Datagrid is being processed (there is only one StdDataFormat object shared by all columns that need the special formatting). The Format/Unformat subroutines have a single parameter, the DataValue object. The DataValue object (a StdFormat object) has two properties, Value and TargetObject. The Value works fine, but the TargetObject, which should give me exactly what I am looking for, is set to Nothing, when I would have expected that it would be set to a Datagrid.Column object.
I stress that the StdDataFormat Format/UnFormat mechanism is working correctly, except that TargetObject is Nothing, preventing me from discriminating between the Columns of the Datagrid.
As an experiment, I wrote a similar program using a Textbox in place of a Datagrid, and in this case the TargetObject was set to the Textbox as expected.
Does anyone out there have experience with using TargetObject with a Datagrid? Is it possible that the TargetObject is not being set because the Datagrid requires complex binding (a field is bound to each column)?