Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

We post number of days in the text box based on which from date and to date are displayed. From Date is by default the system date. The report needs to generate columns based on the no of days posted in the text box. But I am getting error while adding date at runtime to mshflexgrid header column.

It is generating the columns but the last column is generating an error

Can anybody help me to resolve this please.

Thank you very much..
Prerana

the error is : Exception from HRESULT: 0x800A017D (CTL_E_INVALIDPROPERTYARRAYINDEX)
this error is displaying at the last time of loop.
The following is the code:

VB
If i = 3 Then
                        fdate = DateTimePicker1.Value.ToString("MM/dd/yyyy HH:mm:ss tt")
                        sdate = DateTimePicker1.Value.ToString("dd-MM-yyyy")
                        .set_TextMatrix(0, i, sdate)
                    ElseIf i > 3 And i < 34 Then
                        If rbtDaily.Checked = True Then
                            j = 1
                            ndate = (Now.AddDays(j).ToString("MM/dd/yyyy HH:mm:ss tt"))
                            sdate = Now.AddDays(j).ToString("dd-MM-yyyy")
                            '.set_ColWidth(i, 1000) ': .get_GridLinesHeader("'" & ndate & "'")
 error at this line:        .set_TextMatrix(0, i, sdate)
                        ElseIf rbtWeekly.Checked = True Then
                            ndate = DateValue(Now.AddDays(6).ToString("MM/dd/yyyy HH:mm:ss tt"))
                            sdate = Now.AddDays(6).ToString("dd-MM-yyyy")
                            .set_TextMatrix(0, i, sdate)
                        ElseIf rbtMonthly.Checked = True Then
                            j = 1
                            ndate = DateValue(Now.AddMonths(j).ToString("MM/dd/yyyy HH:mm:ss tt"))
                            sdate = Now.AddDays(j).ToString("dd-MM-yyyy")
                            ' tdate = ndate
                            .set_TextMatrix(0, i, sdate)
                        End If
Posted

1 solution

I did not read the complete code (honestly) but looking at the error I could give you one suggestion. something is going wrong on boundary condition. Perhaps the last record. or it seems the collection that you are using has one less item than you are specifying in code. just check the value of "i" when it hits the last column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900