示例#1
0
        //add text box
        protected TextBox TextBox <TProperty>(Expression <Func <TEntity, TProperty> > selector,
                                              string title, bool mutliline = false)
        {
            var label = new Label();

            label.Text     = title;
            label.AutoSize = true;

            var textBox           = new TextBox();
            var expressionHandler = new ExperssionHandler();

            this.Controls.Add(label);
            this.Controls.Add(textBox);

            textBox.DataBindings.Add("Text", Entity, expressionHandler.GetPropertyName(selector));
            textBox.Left      = 20;
            textBox.Top       = 10;
            textBox.Width     = 200;
            textBox.Multiline = true;
            if (mutliline)
            {
                textBox.ScrollBars = ScrollBars.Vertical;
                textBox.Height     = 120;
            }
            createdControls.Add(new EntityEditorControl()
            {
                Label    = label,
                Control  = textBox,
                Priority = createdControls.Count + 1
            });
            return(textBox);
        }
示例#2
0
        //add combo box
        protected ComboBox ComboBox <TProperty, TComboItem>(Expression <Func <TEntity, TProperty> > selector, string title,
                                                            List <TComboItem> items, Expression <Func <TComboItem, string> > displaySelector,
                                                            Expression <Func <TComboItem, TProperty> > valueSelector)
        {
            var expressionHandler = new ExperssionHandler();
            var label             = new Label();

            label.Text     = title;
            label.AutoSize = true;
            this.Controls.Add(label);

            var comboBox = new ComboBox();

            comboBox.DataBindings.Add("SelectedValue", Entity, expressionHandler.GetPropertyName(selector));
            comboBox.DataSource    = items;
            comboBox.DisplayMember = expressionHandler.GetPropertyName(displaySelector);
            comboBox.ValueMember   = expressionHandler.GetPropertyName(valueSelector);
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            this.Controls.Add(comboBox);

            createdControls.Add(new EntityEditorControl()
            {
                Label    = label,
                Control  = comboBox,
                Priority = createdControls.Count + 1
            });

            return(comboBox);
        }
示例#3
0
        public GridControl <TModel> AddTextBoxColumn <TProperty>(string columnName,
                                                                 Expression <Func <TModel, TProperty> > selector)
        {
            var propertyName = new ExperssionHandler().GetPropertyName(selector);

            grid.Columns.Add(new DataGridViewTextBoxColumn
            {
                HeaderText       = columnName,
                DataPropertyName = propertyName
            });

            return(this);
        }
示例#4
0
        //biniding a combobox
        protected void BindComboBox <TProperty, TComboItem>(ComboBox comboBox,
                                                            Expression <Func <TEntity, TProperty> > selector,
                                                            string title,
                                                            List <TComboItem> items,
                                                            Expression <Func <TComboItem, string> > displaySelector,
                                                            Expression <Func <TComboItem, TProperty> > valueSelector)
        {
            var experssionHandler = new ExperssionHandler();

            comboBox.Text = title;
            comboBox.DataBindings.Add("SelectedValue", Entity, experssionHandler.GetPropertyName(selector));
            comboBox.DataSource    = items;
            comboBox.DisplayMember = experssionHandler.GetPropertyName(displaySelector);
            comboBox.ValueMember   = experssionHandler.GetPropertyName(valueSelector);
        }
示例#5
0
        //binding masktextbox
        protected void BindMaskTextBox <TProperty>(MaskedTextBox maskedTextBox, Expression <Func <TEntity, TProperty> > selector)
        {
            var experssionHandler = new ExperssionHandler();

            maskedTextBox.DataBindings.Add("Text", Entity, experssionHandler.GetPropertyName(selector));
        }