-4

Below is my part of code:

I am using GridControl in my project and I would like to put some Input in first column of each row only. I know my code is wrong.Kindly make it correct by suggesting me.

 for(int i=0;i<e.RowIndex;i++)
            {
                for(int j=0;j<e.ColIndex;j++)
                {
                    if(i+j==0)
                        e.Style.CellValue = string.Format("Dwww");
                    int choice = j> i ? i : 99999999;
                    switch(choice)
                    { 
                        case 0:
                           // e.Style.CellValue = string.Format("Derivative");
                            break;
                        case 1:
                            e.Style.CellValue = string.Format("D");
                            break;
                        case 2:
                            e.Style.CellValue = string.Format("ative");
                            break;
                        case 3:
                            e.Style.CellValue = string.Format("Dere");
                            break;
                        case 4:
                            e.Style.CellValue = string.Format("tive");
                            break;
                        case 5:
                            e.Style.CellValue = string.Format("ivati");
                            break;
                        case 6:
                            e.Style.CellValue = string.Format("ankle");
                            break;
                        case 7:
                            e.Style.CellValue = string.Format("ankit");
                            break;
                        case 8:
                            e.Style.CellValue = string.Format("sr");
                            break;
                        case 9:
                            e.Style.CellValue = string.Format("Dsr");
                            break;
                        default:
                            break;

                }
              }
            }

what is the logic for it?

How do I code?

Ankit Raman
  • 79
  • 1
  • 14
  • So where is your code? What have you tried? – Salah Akbari Mar 11 '17 at 08:00
  • How is this stored? Text? Array Variable? List variable? Dictionary? Post-it note? – apokryfos Mar 11 '17 at 08:02
  • `Console.WriteLine("col1\r\ncol5\r\ncol9\r\ncol13");` or use [the checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) to address your question. – rene Mar 11 '17 at 08:02
  • Suppose I have a matrix in above format and I want to print only first column. – Ankit Raman Mar 11 '17 at 08:03
  • If it's a 2 dimentional array (e.g. `var matrix = new string[,] { {},... }`) Then could do `matrix.select(v => v[0]);` to get it as an enumerable and then you can just writing somewhere. – apokryfos Mar 11 '17 at 08:05

1 Answers1

0

this is solution, for in first column

int[,] matrix = new int[4, 4] {{ 1, 2, 3, 4},{ 5, 6, 7, 8},{ 9, 10, 11, 12},{ 13, 14, 15, 16},};
for (int i = 0; i < 4; i++){Console.WriteLine(matrix[i, 0]);}
Console.ReadLine();
Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
Vecchiasignora
  • 1,275
  • 7
  • 6