| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 414 人关注过本帖
标题:关于备忘录的问题
只看楼主 加入收藏
上帝之允
Rank: 1
等 级:新手上路
帖 子:67
专家分:5
注 册:2010-10-11
结帖率:73.68%
收藏
已结贴  问题点数:20 回复次数:1 
关于备忘录的问题
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;
是什么意思??是类实例吗? 怎么这样??谢谢


   
搜索更多相关主题的帖子: 备忘录 
2010-11-09 21:17
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
收藏
得分:14 
只有代码理解起来好像有难度!最好把整个文件都发上来

但是怀疑 private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)这里导致有问题,你可以选择其他日期看看怎么样!!
2010-11-10 16:22
快速回复:关于备忘录的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027282 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved