예제 #1
0
        private void reNameCodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                var code = listBox1.SelectedItem as Code;
                if (code != null)
                {
                    //var newName = GetFileName(code.Title);
                    var formName = new FormGetText();
                    formName.Title     = "请输入代码名称";
                    formName.LableText = "代码名:";
                    formName.Result    = code.Title;
                    formName.ShowDialog();
                    if (!string.IsNullOrEmpty(formName.Result))
                    {
                        var list = listBox1.DataSource as List <Code>;
                        list.Remove(code);
                        code.Title = formName.Result;
                        code       = db.SaveCode(code);

                        list.Add(code);
                        listBox1.DataSource    = null;
                        listBox1.DataSource    = list;
                        listBox1.DisplayMember = "Title";
                    }
                }
            }
        }
예제 #2
0
        private String GetFileName(String oldName = "")
        {
            var frm = new FormGetText();

            frm.StartPosition = FormStartPosition.Manual;
            frm.Location      = new Point(Control.MousePosition.X, Control.MousePosition.Y);
            frm.Result        = oldName;
            frm.LableText     = "文件名:";
            frm.Title         = "输入文件名";
            frm.ShowDialog();
            var result = frm.Result;

            frm.Dispose();
            frm = null;
            return(result);
        }