本人只会B/S程序,winform 一点不会,
我在网上找到这个代码,怎么放到winform 里头?这个是winform 里面自动生成的
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
以下是我在网上找到的
using System; namespace CNCalendar
{
public class CNDate
{
private const ushort START_YEAR = 1901;
private const ushort END_YEAR = 2050;
private string[] ConstellationName =
{
"白羊座", "金牛座", "双子座",
"巨蟹座", "狮子座", "处女座",
"天秤座", "天蝎座", "射手座",
"摩羯座", "水瓶座", "双鱼座"};
private string[] LunarHolDayName =
{
"小寒", "大寒", "立春", "雨水",
"惊蛰", "春分", "清明", "谷雨",
"立夏", "小满", "芒种", "夏至",
"小暑", "大暑", "立秋", "处暑",
"白露", "秋分", "寒露", "霜降",
"立冬", "小雪", "大雪", "冬至"}; //中间省略很多............................................public class Test
{
static void Main(string[] args)
{
CNDate dt = new CNDate(DateTime.Today);
Console.WriteLine("今天是:" + dt.Date.ToString() + dt.GetConstellationName());
Console.WriteLine(dt.l_GetLunarHolDay());
Console.WriteLine(dt.GetLunarHolDay());
Console.WriteLine("闰月" + dt.GetLeapMonth(UInt16.Parse(args[0])));
Console.WriteLine("2月的天数" + dt.LunarMonthDays(UInt16.Parse(args[0]), UInt16.Parse(args[1])));
Console.WriteLine("天数" + dt.LunarYearDays(UInt16.Parse(args[0])));
Console.WriteLine("" + dt.FormatLunarYear());
dt.Date = DateTime.Today.AddDays(1);
Console.WriteLine("明天是:" + dt.Date.ToString() + dt.GetConstellationName());
}
} //class Test
}
我在网上找到这个代码,怎么放到winform 里头?这个是winform 里面自动生成的
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
以下是我在网上找到的
using System; namespace CNCalendar
{
public class CNDate
{
private const ushort START_YEAR = 1901;
private const ushort END_YEAR = 2050;
private string[] ConstellationName =
{
"白羊座", "金牛座", "双子座",
"巨蟹座", "狮子座", "处女座",
"天秤座", "天蝎座", "射手座",
"摩羯座", "水瓶座", "双鱼座"};
private string[] LunarHolDayName =
{
"小寒", "大寒", "立春", "雨水",
"惊蛰", "春分", "清明", "谷雨",
"立夏", "小满", "芒种", "夏至",
"小暑", "大暑", "立秋", "处暑",
"白露", "秋分", "寒露", "霜降",
"立冬", "小雪", "大雪", "冬至"}; //中间省略很多............................................public class Test
{
static void Main(string[] args)
{
CNDate dt = new CNDate(DateTime.Today);
Console.WriteLine("今天是:" + dt.Date.ToString() + dt.GetConstellationName());
Console.WriteLine(dt.l_GetLunarHolDay());
Console.WriteLine(dt.GetLunarHolDay());
Console.WriteLine("闰月" + dt.GetLeapMonth(UInt16.Parse(args[0])));
Console.WriteLine("2月的天数" + dt.LunarMonthDays(UInt16.Parse(args[0]), UInt16.Parse(args[1])));
Console.WriteLine("天数" + dt.LunarYearDays(UInt16.Parse(args[0])));
Console.WriteLine("" + dt.FormatLunarYear());
dt.Date = DateTime.Today.AddDays(1);
Console.WriteLine("明天是:" + dt.Date.ToString() + dt.GetConstellationName());
}
} //class Test
}
解决方案 »
- 求高手 给 这段代码 优化一下
- nhibernate的GuidComb生成器。
- 我在用报表的时候想实现这样的功能。
- c#如何访问java
- 在一个类里的很多地方要格式化一个DateTime,应该用个什么变量来统一控制,这样就不用每次都单独格式化,弄不好还可能不一致?
- 串行通信控件
- 高分寻求打印最快速度方案,一张票据客户要求最慢不超过五秒!急!!
- webbrowser控件如何禁用滚动条呢?
- 怎么将编译好的程序打包,并可以在另外一台机器上变成可执行的程序?它包括对服务器上的数据处理
- 谁能给我一个(完整的)C#画图的例子76分!!??????
- 连接sql server2000一直报错
- C#到底能做些什么?
http://dotnet.aspx.cc/ShowDetail.aspx?id=AD2E10B2-0020-4C73-82D7-873164688E2D
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
放在form1的构造函数里
就可以了