Beispiel #1
0
        void Editor_ValueChanged(object sender, EventArgs e)
        {
            EmbeddableEditorBase editor = sender as EmbeddableEditorBase;
            UltraGridRow         r      = editor.Tag as UltraGridRow;
            string propName             = r.ParentRow.Cells[fieldName].Value as string;
            string optName = r.Cells["PropOptName"].Value as string;

            // 更新选择表内容
            foreach (DataRow row in this.subOptTable.Rows)
            {
                if (((string)row["PropName"] == propName) &&
                    ((string)row["PropOptName"] == optName))
                {
                    row["PropOptVal"] = editor.Value;
                    break;
                }
            }

            foreach (DataRow r2 in this.dataTable.Rows)
            {
                if ((string)r2[fieldName] == propName)
                {
                    r2[fieldValue] = this.GetOptString(propName);
                    break;
                }
            }

            r.Selected = true;
            r.Activate();
        }
Beispiel #2
0
        private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
        {
            EmbeddableEditorBase       editor         = null;
            DefaultEditorOwnerSettings editorSettings = null;

            editorSettings          = new DefaultEditorOwnerSettings( );
            editorSettings.DataType = typeof(int);
            editor = new EditorWithMask(new DefaultEditorOwner(editorSettings));
            editorSettings.MaskInput       = "nnnn";
            e.Row.Cells["cnvcFree"].Editor = editor;
        }
Beispiel #3
0
        private void dgvArticulos_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                UltraGrid     grid       = sender as UltraGrid;
                UltraGridCell activeCell = grid == null ? null : grid.ActiveCell;

                // if there is an active cell, its not in edit mode and can enter edit mode
                if (null != activeCell && false == activeCell.IsInEditMode && activeCell.CanEnterEditMode)
                {
                    // if the character is not a control character
                    if (char.IsControl(e.KeyChar) == false)
                    {
                        // try to put cell into edit mode
                        grid.PerformAction(UltraGridAction.EnterEditMode);

                        // if this cell is still active and it is in edit mode...
                        if (grid.ActiveCell == activeCell && activeCell.IsInEditMode)
                        {
                            // get its editor
                            EmbeddableEditorBase editor = activeCell.EditorResolved;

                            // if the editor supports selectable text
                            if (editor.SupportsSelectableText)
                            {
                                // select all the text so it can be replaced
                                editor.SelectionStart  = 0;
                                editor.SelectionLength = editor.TextLength;

                                if (editor is EditorWithMask)
                                {
                                    // just clear the selected text and let the grid
                                    // forward the keypress to the editor
                                    editor.SelectedText = string.Empty;
                                }
                                else
                                {
                                    // then replace the selected text with the character
                                    editor.SelectedText = new string(e.KeyChar, 1);

                                    // mark the event as handled so the grid doesn't process it
                                    e.Handled = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获得表格单元所使用的内嵌编辑器
        /// </summary>
        /// <param name="editorType"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        EmbeddableEditorBase GetEmbeddableEditor(string editorType, object tag)
        {
            EmbeddableEditorBase       editor         = null;
            DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings();

            switch (editorType)
            {
            default:
            case "String":
            case "Text":
                editorSettings.DataType = typeof(string);
                return(new EditorWithText(new DefaultEditorOwner(editorSettings)));

            case "Color":
                editorSettings.DataType = typeof(Color);
                return(new ColorPickerEditor(new DefaultEditorOwner(editorSettings)));

            case "Font":
                ValueList valueList = new ValueList();
                editorSettings.DataType = typeof(string);
                for (int i = 0; i < System.Drawing.FontFamily.Families.Length; i++)
                {
                    valueList.ValueListItems.Add(System.Drawing.FontFamily.Families[i].Name);
                }
                editorSettings.ValueList = valueList;
                return(new FontNameEditor(new DefaultEditorOwner(editorSettings)));

            case "Int":
                editorSettings.DataType = typeof(int);
                editor = new EditorWithMask(new DefaultEditorOwner(editorSettings));
                editorSettings.MaskInput = "-nnnnnnnn";
                return(editor);

            case "Progress":
                editorSettings.DataType = typeof(int);
                return(new Infragistics.Win.UltraWinProgressBar.ProgressBarEditor(new DefaultEditorOwner(editorSettings)));

            case "Date":
                editorSettings.DataType  = typeof(DateTime);
                editorSettings.MaskInput = "yyyy-mm-dd";
                return(new DateTimeEditor(new DefaultEditorOwner(editorSettings)));

            case "Time":
                editorSettings.DataType  = typeof(DateTime);
                editorSettings.MaskInput = "hh:mm:ss";
                return(new EditorWithMask(new DefaultEditorOwner(editorSettings)));

            case "DateTime":
                editorSettings.DataType  = typeof(DateTime);
                editorSettings.MaskInput = "yyyy-mm-dd hh:mm:ss";
                return(new DateTimeEditor(new DefaultEditorOwner(editorSettings)));

            case "Double":
            case "Float":
                editorSettings.DataType  = typeof(double);
                editorSettings.MaskInput = "-nnnnnnnn.nnn";
                return(new EditorWithMask(new DefaultEditorOwner(editorSettings)));

            case "IP":
                editorSettings.DataType = typeof(string);
                editor = new EditorWithMask(new DefaultEditorOwner(editorSettings));
                editorSettings.MaskInput = "nnn\\.nnn\\.nnn\\.nnn";
                return(editor);

            case "YesNoDropDown":
                editorSettings.DataType = typeof(bool);
                valueList = new ValueList();
                valueList.ValueListItems.Add(true, "是");
                valueList.ValueListItems.Add(false, "否");
                editorSettings.ValueList = valueList;
                return(new EditorWithCombo(new DefaultEditorOwner(editorSettings)));

            case "YesNoCheckBox":
                editorSettings.DataType = typeof(bool);
                return(new CheckEditor(new DefaultEditorOwner(editorSettings)));

            case "Enum":
            case "CustomEnum":
                List <string> slist = tag as List <string>;
                ValueList     vlist = new ValueList();
                if (slist != null)
                {
                    foreach (string str in slist)
                    {
                        vlist.ValueListItems.Add(str);
                    }
                }
                editorSettings.ValueList = vlist;
                editorSettings.DataType  = typeof(string);
                editor = new EditorWithCombo(new DefaultEditorOwner(editorSettings));
                return(editor);
            }
        }