第十五篇

处理TEXTBOX  改动后将值保存到TAG中
BUTTONEDIT  改动后将值保存到OLDVALUE中
 
            foreach (Control aControl in panelBottom.Controls)
            {
                
if (aControl is ButtonEdit )
                {                     
                    
//aControl.Enabled = false;
                    ((BaseEdit)aControl).TextChanged += delegate(object sender1, EventArgs e1)
                    {
                        
//if (!(Sheetid.Text == null || Sheetid.Text.Equals("")))
                       if(((BaseEdit)sender1).IsModified ==false)
                        {
                            ((BaseEdit)sender1).IsModified
=true;
                            hasDataChange 
= true;
                            Save.Enabled 
=Cancel.Enabled = true;
                        }
                    };
                }
                
if (aControl is TextBox)
                {
                    ((TextBox)aControl).TextChanged 
+= delegate(object sender2, EventArgs e2)
                    {
                        
if (((TextBox)sender2).Tag == null)
                        {
                            TextBox TextBoxOther 
= (TextBox)sender2;
                            TextBoxOther.Undo();
                            ((TextBox)sender2).Tag 
= TextBoxOther.Text.ToString();
                            hasDataChange = true;
                            Save.Enabled 
=Cancel.Enabled = true;

                        }
                    };
                }
            }
 
取消的时候
 
  foreach (Control aControl in panelTop.Controls)
            {
                if (aControl is ButtonEdit)
                {
                    BaseEdit edit = aControl as BaseEdit;
                    if (edit.IsModified)
                    {
                       edit.EditValue = edit.OldEditValue;
                        edit.IsModified = false;
                    }
                }
                if (aControl is TextBox)
                {
                    TextBox edit = aControl as TextBox;
                    if (edit.Tag != null )
                    {
                        edit.Text = edit.Tag.ToString();
                        edit.Tag = null;
                    }
                }
            }
 
 
posted @ 2011-07-30 08:25  Ry5  阅读(200)  评论(0编辑  收藏  举报