
public MyForm()
{
InitializeComponent();
this.Resize += new System.EventHandler(this.FormResize);
Load += new System.EventHandler(MyForm_Load);
}
// アプリケーションの初期化
private void MyForm_Load(object sender, System.EventArgs e)
{
ReadFile("C:\\TMP\\test2.mem");
m_Idx = 0;
treeView1.TopNode.Expand();
richTextBox1.Text = (string)t_txt[0];
}
|
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(326, 495);
this.treeView1.TabIndex = 0;
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
// Tree View の選択が変更された時の処理
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
CheckText();
for (m_Idx = 0; m_Idx < t_node.Count && (TreeNode)t_node[m_Idx] != e.Node; m_Idx++);
if (m_Idx < t_node.Count)
{
richTextBox1.Text = (string)t_txt[m_Idx];
richTextBox1.Select(m_Idx, 0);
Title.Text = (string)t_ttl[m_Idx] + "(" + (string)t_ymd[m_Idx] + ")";
}
}
|
// richTextBox1 を調べて ArrayList を更新
private void CheckText()
{
if (richTextBox1.Modified && m_Idx<t_txt.Count)
{
t_txt[m_Idx] = richTextBox1.Text;
SetDate(m_Idx);
m_UP = true;
richTextBox1.Modified = false;
}
}
|
// 更新日付の設定
private void SetDate(int idx)
{
string ymd, str;
str = DateTime.Now.ToString();
ymd = (string)t_ymd[idx];
if (ymd.Length < 20) // YYMMDD:YYMMDD
{
str = "20" + ymd.Substring(0, 2) + "/" + ymd.Substring(2, 2) + "/"
+ ymd.Substring(4, 2) + ":" + str.Substring(0, 10);
}
else // YYYY/MM/DD:YYYY/MM/DD
{ str = ymd.Substring(0, 11) + str.Substring(0, 10); }
t_ymd[idx] = str;
}
|
[Next Chapter ↓] Menu を登録
[Previous Chapter ↑] Memo Tree View