Printing a DataGridView

Posted by joelwins on 25-Oct-2012 01:47

Dear All,

I working in OE 10.2A.

I am using the following method to generate a CSV file from a datagridview.

But sometimes I get the following error.

Die ersten Attribute in einem chained-attribute-Ausdruck (a:b:c) müssen entweder vom Typ HANDLE sein, oder ein gültiger (nicht UNKNOWN) benutzerdefinierter Typ sein . (10068)

Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not UNKNOWN). (10068)

I think that it is because of the "end of file' kind of condition of may be because of NULL values. Could someone confirm the same.

Also could someone let me know if there is a better way to export to a CSV format?

Thanks & best regards,

Joel

    METHOD PRIVATE VOID OutputGridMo():

        DEFINE VARIABLE GridRow        AS System.Windows.Forms.DataGridViewRow  NO-UNDO.
        DEFINE VARIABLE GridRowCell0   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell1   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell2   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell3   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell4   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell5   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell6   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell7   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell8   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell9   AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE GridRowCell10  AS System.Windows.Forms.DataGridViewCell NO-UNDO.
        DEFINE VARIABLE iRowIndex      AS INTEGER                               NO-UNDO.
        DEFINE VARIABLE iIter          AS INTEGER                               NO-UNDO.
        DEFINE VARIABLE OutputPathFile AS CHARACTER                             NO-UNDO.
        DEFINE VARIABLE strHeader AS CHARACTER                             NO-UNDO.

        IF dataGridViewMo:RowCount > 0 THEN
        DO:
            OutputPathFile = OutputFileName("Modellhitliste", iCurrentMarke).
            OUTPUT TO VALUE(OutputPathFile).

            strHeader = "".
            DO iIter = 0 TO dataGridViewMo:Columns:Count - 1:
                strHeader = strHeader + (IF strHeader = "" THEN "" ELSE ",") + '"' + dataGridViewMo:Columns[iIter]:HeaderText + '"'.
            END.
            PUT UNFORMATTED strHeader SKIP.
           
            DO iIter = 0 TO dataGridViewMo:RowCount - 1:
                GridRow = dataGridViewMo:Rows[iIter].
       
                GridRowCell0 = GridRow:Cells[0].
                GridRowCell1 = GridRow:Cells[1].
                GridRowCell2 = GridRow:Cells[2].
                GridRowCell3 = GridRow:Cells[3].
                GridRowCell4 = GridRow:Cells[4].
                GridRowCell5 = GridRow:Cells[5].
                GridRowCell6 = GridRow:Cells[6].
                GridRowCell7 = GridRow:Cells[7].
                GridRowCell8 = GridRow:Cells[8].
                GridRowCell9 = GridRow:Cells[9].
                GridRowCell10 = GridRow:Cells[10].
               
                EXPORT DELIMITER ","
                    GridRowCell0:Value:ToString()
                    GridRowCell1:Value:ToString()
                    GridRowCell2:Value:ToString()
                    GridRowCell3:Value:ToString()
                    GridRowCell4:Value:ToString()
                    GridRowCell5:Value:ToString()
                    GridRowCell6:Value:ToString()
                    GridRowCell7:Value:ToString()
                    GridRowCell8:Value:ToString()
                    GridRowCell9:Value:ToString()
                    GridRowCell10:Value:ToString().
       
            END.
            OUTPUT CLOSE.
            MESSAGE "Ausgabe in " OutputPathFile VIEW-AS ALERT-BOX.
        END.   
       
    END METHOD.

All Replies

Posted by Admin on 25-Oct-2012 01:58

I working in OE 10.2A.

 

Seriously?

Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not UNKNOWN). (10068)

 

Which source code row does raise the error message? Try to create the compiler's debug-listing and see where exactly the error comes from.

Also could someone let me know if there is a better way to export to a CSV format?

I personally would prefer to export directly from the underlying Query or ProDataset and not through the visual Control. Visual Controls are a matter of fashion. They change.

Posted by joelwins on 25-Oct-2012 02:06

Thanks Mike. I will export from the prodataset.

Regards,

Joel

This thread is closed