1
Answer

C#NET2008 Window Application using SWITCH CASE

Lennie Kuah

Lennie Kuah

13y
1.6k
1
Hullo Friends,
I do neet you help, Please help me.
I do encounter an interesting problem with the C#NET Windown Application using SWITCH CASE in the coding.

In order to format the EXCEL WorkSheet 10 columns which the Column1 - 3 should have the same width.
and Column 5 - 8 should also have the same width.

I am trying to use this coding and it's not working:

int intColumn = 0;
int intRecCount = DR.FieldCount;

For (intColumn = 1 ; intcolumn < - intRecCount; intColumn ++)
(

        Switch (intColumn)
        {
             case 1:2:3:
              ((Range)xlWrkSheet.Cells[intRow, intColumn]).EntireColumn.ColumnWidth = 13;
              break;

             case 4:
             ((Range_xlWrkSheet.Cells[intRow, intColumn]).EntireColumn.columnWidth = 10;
             break;

             case 5:6:7:8: 
             ((Range)xlWrkSheet.Cells[intRow, intColumn]).EntireColumn.ColumnWidth = 20;
              break;
        }
}


Thank you for your help.
Cheers,
Lennie Kuah
Answers (1)