object Infragistics.Win.IEditorDataFilter.Convert(Infragistics.Win.EditorDataFilterConvertArgs args) { object value; if (args.Value != null) { value = args.Value.ToString(); } return(args.Value); //switch (args.Direction) //{ // //case ConversionDirection.EditorToOwner: // // args.Handled = true; // // if (args.Value == null) return "N"; // // if (args.Value.ToString().ToUpper() == "CHECKED" || args.Value.ToString().ToUpper() == "TRUE" || args.Value.ToString().ToUpper() == "Y") // // { // // state = CheckState.Checked; // // } // // else // // { // // state = CheckState.Unchecked; // // } // // switch (state) // // { // // case CheckState.Checked: // // return "Y"; // // case CheckState.Unchecked: // // return "N"; // // case CheckState.Indeterminate: // // return "N"; // // } // // break; // case ConversionDirection.OwnerToEditor: // args.Handled = true; // return args.Value; // case ConversionDirection.EditorToDisplay: // break; //} //throw new Exception("Invalid value passed into CheckEditorDataFilter.Convert()"); }
object Infragistics.Win.IEditorDataFilter.Convert(Infragistics.Win.EditorDataFilterConvertArgs args) { switch (args.Direction) { case ConversionDirection.EditorToOwner: args.Handled = true; if (args.Value == null) { return("N"); } if (args.Value.ToString().ToUpper() == "CHECKED" || args.Value.ToString().ToUpper() == "TRUE" || args.Value.ToString().ToUpper() == "Y") { state = CheckState.Checked; } else { state = CheckState.Unchecked; } switch (state) { case CheckState.Checked: return("Y"); case CheckState.Unchecked: return("N"); case CheckState.Indeterminate: return("N"); } break; case ConversionDirection.OwnerToEditor: args.Handled = true; if (args.Value == null) { return(CheckState.Unchecked); } if (args.Value.ToString() == "Y" || args.Value.ToString().ToUpper() == "TRUE") { return(CheckState.Checked); } else { return(CheckState.Unchecked); } //使用三相時 //if (args.Value.ToString() == "Y" || args.Value.ToString().ToUpper() == "TRUE") // return CheckState.Checked; //else if (args.Value.ToString() == "N" || args.Value.ToString().ToUpper() == "False") // return CheckState.Unchecked; //else // return CheckState.Indeterminate; //else if (args.Value.ToString() == "N" || args.Value.ToString().ToUpper() == "FALSE") // return CheckState.Unchecked; //else // return CheckState.Indeterminate; } throw new Exception("Invalid value passed into CheckEditorDataFilter.Convert()"); }