narasiman rao

narasiman rao

  • NA
  • 519
  • 771.7k

date picker foramt to be date and month in DGv month as JAN

Jan 10 2013 6:59 AM
  design as follows in data grid view;;

Date  Session  Column name  Column name Column name Column name Column name

18 1  1
18 1  2
18 1  3
18 1  4

in run mode  date  inpicker format is  date, month in data grid view.
month should be character as example jan

Code as follows;

  int iRow = 0;
  this.datagridView.RowCount = 24;
  for (int i = 0; i < 6; i++)
  {
  DateTime newDate = dt_startweek.Value.AddDays(i);
  for (int newIndex = 1; newIndex <= 4; newIndex++)
  {
   
datagridView[0, iRow].Value = newDate.Day.ToString() +"" + newDate.Month.ToString();
  datagridView[1,iRow].Value = newIndex.ToString();
  iRow = iRow + 1;
  }
  }

  //datagridView[0,iRow].Value = newDate.ToShortDateString().ToString();

for the month code in data grid view mention code as

datagridView[0, iRow].Value = newDate.Day.ToString() +"" + newDate.Month.ToString();


that month shluld be character as jan not '1' in number.

output as follows in run mode in data grid view.the month to be char like Jan

Date  Session  Column name  Column name Column name Column name Column name

18 jan  1
18 jan  2
18 jan  3
18 jan  4
 


try this
datagridView[0, iRow].Value = newDate.Day.ToString() +"" + newDate.Month.ToString("MMM");


i try your solution above solution but the output shows as

Date  Session  Column name  Column name Column name Column name Column name

18 MMM 1
18 MMM 2
18 MMM 3
18 MMM 4

not shows the correct output .

i want the output as follows;

18 jan  1
18 jan  2
18 jan  3
18 jan  4
 



Answers (1)