Exemplo n.º 1
0
 private void lsMain_DrawItem(object sender, DrawItemEventArgs e)
 {
     if (e.Index >= 0)
     {
         e.DrawBackground();
         IndexText master = ((ListBox)sender).Items[e.Index] as IndexText;
         e.Graphics.DrawString(master.Index.ToString(), e.Font, new SolidBrush(Color.Red), e.Bounds);
         e.Graphics.DrawString(master.Text.Replace('\n', ' '), e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + 32, e.Bounds.Top);
     }
 }
Exemplo n.º 2
0
        private void btnEnsure_Click(object sender, EventArgs e)
        {
            IndexText kv = lsMain.SelectedItem as IndexText;

            kv.Text = txtEdit.Text.Replace("\r\n", "\n");

            btnSave.Enabled = true;

            lsMain.Refresh();

            tsmiState.Text      = "修改成功,等待写入";
            tsmiState.ForeColor = Color.Blue;
        }
Exemplo n.º 3
0
        private void lsMain_SelectedIndexChanged(object sender, EventArgs e)
        {
            IndexText txt = lsMain.SelectedItem as IndexText;

            if (txt == null)
            {
                txtEdit.Enabled   = false;
                btnEnsure.Enabled = false;
            }
            else
            {
                txtEdit.Enabled   = true;
                btnEnsure.Enabled = true;
                txtEdit.Text      = txt.Text.Replace("\n", "\r\n");
            }
            tsmiState.Text      = "等待修改";
            tsmiState.ForeColor = Color.Black;
        }