Пример #1
0
        //No async!
        private /*async*/ void StdDataGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
        {
            //await Task.Factory.StartNew(() =>
            //{
            DataGridView senderGrid = (DataGridView)sender;

            if (e.Row.Index < 0)
            {
                return;
            }
            senderGrid.CellValueChanged -= StdDataGridView_CellValueChanged;
            foreach (DataGridViewCell cell in e.Row.Cells)
            {
                if (!BindingSourcesComboBox.ContainsKey(senderGrid.Columns[cell.ColumnIndex].DataPropertyName))
                {
                    continue;
                }
                dynamic data = BindingSourcesComboBox[senderGrid.Columns[cell.ColumnIndex].DataPropertyName]
                               .Current;

                //PropertyInfo field = GetType().GetProperty(fieldName);
                //if (field != null) field.SetValue(this, Convert.ChangeType(value, field.PropertyType));

                //var data = _bindingSourcesComboBox[senderGrid.Columns[cell.ColumnIndex].DataPropertyName]
                //    .Current;

                //Type t = typeof(StandardKeyValuePair<int, string>);

                //data = Convert.ChangeType(data, t);

                cell.Value = data.Key;
            }
            senderGrid.CellValueChanged += StdDataGridView_CellValueChanged;
            //});
        }
Пример #2
0
        private void Initialize()
        {
            foreach (var propertyInfo in typeof(TList).GetProperties())
            {
                if (!propertyInfo.Name.Equals("List"))
                {
                    BindingSourcesComboBox.Add(propertyInfo.Name, null);
                }
            }

            AutoGenerateColumns = false;

            DataGridViewColumn col = new StdDataGridViewFunctionColumn();

            Columns.Add(col);

            CreateColumns();
        }
        private void Initialize()
        {
            AutoGenerateColumns   = false;
            AllowUserToAddRows    = false;
            AllowUserToDeleteRows = false;
            AllowDrop             = false;

            foreach (var propertyInfo in typeof(TList).GetProperties())
            {
                if (!propertyInfo.Name.Equals("List"))
                {
                    BindingSourcesComboBox.Add(propertyInfo.Name, null);
                }
            }
            //AutoGenerateColumns = true;
            //AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;



            //DataGridViewColumn col = new StdDataGridViewFunctionColumn();
            //Columns.Add(col);

            CreateColumns();
        }