(1) In below code how to add day node.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace msg
{
public partial class TreeViewControl : Form
{
public TreeViewControl()
{
InitializeComponent();
}
private void TreeViewControl_Load(object sender, EventArgs e)
{
//System.Globalization.DateTimeFormatInfo d = new System.Globalization.DateTimeFormatInfo();
DateTimeFormatInfo d = new DateTimeFormatInfo();
for (int yearnum = 1989; yearnum <= 2013; yearnum++)
{
TreeNode yearnode = new TreeNode();
yearnode.Text = yearnum.ToString();
treeView1.Nodes.Add(yearnode);
for (int monthnum = 0; monthnum < 12; monthnum++)
{
TreeNode monthnode = new TreeNode();
//monthnode.Text = monthnum.ToString();
//monthnode.Text=DateTimeFormatInfo.CurrentInfo.MonthNames[monthnum].ToString();
monthnode.Text =d.MonthNames[monthnum].ToString();
yearnode.Nodes.Add(monthnode);
}
}
}
}
}
(2) where i found complete hierarchy of namespace their class and their methods and properties because sometimes i faced problem "You are missing directive or an assembly reference ".
(2) where i found complete hierarchy of namespace their class and their methods and properties because sometimes i faced problem "You are missing directive or an assembly reference ".
Blocked AccountPosted Mar 8, 2013, 4:58 AM
DateTimeFormatInfo d = new DateTimeFormatInfo();
int yearnum;
int monthnum;
for (yearnum = 1989; yearnum <= 2013; yearnum++)
{
TreeNode yearnode = new TreeNode();
yearnode.Text = yearnum.ToString();
treeView1.Nodes.Add(yearnode);
for (monthnum = 1; monthnum <= 12; monthnum++)
{
TreeNode monthnode = new TreeNode();
monthnode.Text = d.MonthNames[monthnum-1].ToString();
yearnode.Nodes.Add(monthnode);
int s = DateTime.DaysInMonth(yearnum, monthnum);
for (int daynum = 1; daynum <= s; daynum++)
{
TreeNode daynode = new TreeNode();
daynode.Text = daynum.ToString();
monthnode.Nodes.Add(daynode);
}
}
}
Arun KurmiPosted Mar 8, 2013, 10:58 AM
thanks this is working.
why we take [monthnum-1] in below statement:
monthnode.Text = d.MonthNames[monthnum-1].ToString();
////////////////////////////////////////////////////
before your suggestion i tried something like given below.Whats mistake in below code:
for (int daynum = 0; daynum <= d.Calendar.GetDaysInMonth(yearnum, (monthnum + 1)); daynum++)
{
TreeNode daynode = new TreeNode();
daynode.Text = daynum.ToString();
System.DateTime dn = new DateTime(yearnum, monthnum + 1, daynum + 1, 0, 0, 0);
daynode.Text = dn.ToString("dd dddd");
monthnode.Nodes.Add(daynode);
}