コード例 #1
0
        protected void RowChangingEventHandler(object sender,
                                               DataRowChangeEventArgs e)
        {
            try
            {
                DataRow row = e.Row;
                switch (e.Action)
                {
                case (DataRowAction.Add):
                {
                    //throw (new Exception("Cannot add rows"));
                    break;
                }

                case (DataRowAction.Change):
                {
                    //if this is an object, datetime, enum or ref property changing,
                    //bring up custom UI for editing these!!!!
                    if (gridMode == GridMode.EditMode)
                    {
                        //this can only be value change
                        Property propAffected = (Property)this.rowPropertyMap[row];                                 //mgmtObj.Properties[row[propNameColumn].ToString()];

                        if (propAffected.Type == CimType.Object)
                        {
                            ////MessageBox.Show("should bring up custom type editor for objects");
                        }

                        if (propAffected.Type == CimType.Reference)
                        {
                            //MessageBox.Show("should bring up custom type editor for refs");
                        }

                        if (propAffected.Type == CimType.DateTime)
                        {
                            //MessageBox.Show("should bring up custom type editor for datetime");
                        }

                        if (WmiHelper.IsValueMap(propAffected))
                        {
                            //MessageBox.Show("should bring up custom type editor for enums");
                        }
                    }
                    break;
                }

                case (DataRowAction.Commit):
                {
                    //MessageBox.Show("DataRowAction.Commit");
                    break;
                }

                case (DataRowAction.Delete):
                {
                    throw (new Exception("Cannot delete rows"));
                }

                case (DataRowAction.Nothing):
                {
                    MessageBox.Show("DataRowAction.Nothing");
                    break;
                }

                case (DataRowAction.Rollback):
                {
                    MessageBox.Show("DataRowAction.Rollback");
                    break;
                }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw(exc);
            }
        }