关于备忘录的问题
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 超市商品管理系统
{
public partial class Form5 : Form
{
System.Collections.ArrayList memoItems = new System.Collections.ArrayList();
public Form5()
{
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
}
private bool findMemoByDate(DateTime date, out MemoEntry memo)
{
memo = null;
for (int i = 0; i < memoItems.Count; i++)
{
memo = (MemoEntry)(memoItems[i]);//类型转换
if (memo.date == date)
{
return true;
}
memo = null;
return false;
}
return false;
}
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
MemoEntry memo;
if (findMemoByDate(e.Start, out memo))
{
textBox1.Text = memo.content;
delete.Enabled = true;
}
else
{
textBox1.Clear();
delete.Enabled = false;
}
}
private void save_Click(object sender, EventArgs e)
{
MemoEntry memo;
DateTime date = monthCalendar1.SelectionStart;
if(textBox1.Text.Trim()=="")
{
if(findMemoByDate(date,out memo))
{
memoItems.Remove(memo);
}
delete.Enabled=false;
}
else
{
if(findMemoByDate(date,out memo))
{
memo.content=textBox1.Text.Trim();
}
else
{
memoItems.Add(new MemoEntry(date,textBox1.Text.Trim()));
}
monthCalendar1.AddBoldedDate(date);
monthCalendar1.UpdateBoldedDates();
delete.Enabled=true;
}
}
private void delete_Click(object sender, EventArgs e)
{
MemoEntry memo;
DateTime date=monthCalendar1.SelectionStart;
if(findMemoByDate(date,out memo))
{
memoItems.Remove(memo);
monthCalendar1.RemoveBoldedDate(date);
monthCalendar1.UpdateBoldedDates();
}
}
private void exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
internal sealed class MemoEntry
{
internal MemoEntry(DateTime d, string s)
{
date = d;
content = s;
}
private DateTime memoDate;
public DateTime date
{
get
{
return memoDate;
}
set
{
memoDate = value;
}
}
private string memoContent;
public String content
{
get { return memoContent; }
set { memoContent = value; }
}
}
}
刚开始接触C#。。
生成备忘录之后,连续存储几个日期的备忘录之后,再次点击日期的时候只能在textbox中,显示第一次存储的备忘,
只有删除了第一个,第二个才可以看,以此类推,不知道为什么,求解,还有就是关于 private bool findMemoByDate(DateTime date, out MemoEntry memo)中out是怎么理解?? 最后的问题是
private void delete_Click(object sender, EventArgs e)
{
MemoEntry memo;
DateTime date=monthCalendar1.SelectionStart;
中MemoEntry memo;
是什么意思??是类实例吗? 怎么这样??谢谢