public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    ListBoxControl dbs = new ListBoxControl();
                    dbs.Click += Dbs_Click;

                    try
                    {
                        QDocumentCR       doc    = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
                        List <QPoolField> fields = doc.GetDescendants <QPoolField>();
                        List <String>     tables = fields.Select(cr => cr.TableName).Distinct().ToList();
                        dbs.DataSource = tables;
                        edSvc.DropDownControl(dbs);
                        value = dbs.SelectedItem;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            return(value);
        }
Beispiel #2
0
        private List <QPoolField> GetDataSource(ITypeDescriptorContext context)
        {
            QDocumentCR       doc    = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
            List <QPoolField> fields = doc.GetDescendants <QPoolField>();

            return(fields);
        }
        private List <QPoolField> GetDataSource(ITypeDescriptorContext context)
        {
            // get document
            QDocumentCR doc = null;

            if (context.Instance is QCRModifier)
            {
                doc = (QDocumentCR)(((QCRModifier)context.Instance).ChangeRequest).GetRoot();
            }
            else if (context.Instance is QChangeRequest)
            {
                doc = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
            }
            List <QPoolField> fields = doc.GetDescendants <QPoolField>();

            return(fields);
        }
        private object InitDropDown_Criterio(ITypeDescriptorContext context, ListBoxControl dbs)
        {
            object retval = null;

            try
            {
                QDocumentCR       doc    = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
                List <QPoolField> fields = doc.GetDescendants <QPoolField>();
                dbs.DisplayMember = "FieldName";
                dbs.DataSource    = fields;
                edSvc.DropDownControl(dbs);
                retval = ((QPoolField)dbs.SelectedItem).FieldName;
            }
            catch (Exception ex)
            {
            }
            return(retval);
        }
        private List <QPoolField> GetDataSource(ITypeDescriptorContext context)
        {
            QDocumentCR       doc    = (QDocumentCR)((QChangeRequest)context.Instance).GetRoot();
            List <QPoolField> fields = doc.GetDescendants <QPoolField>();
            object            inst   = context.Instance;

            if (inst.GetType() == typeof(QAddCriterioCR))
            {
                // return only those belonging to table
                string tableName = (string)context.Instance.GetType().GetProperty("WhereTable").GetValue(context.Instance, null);
                return(fields.Where(p => p.TableName == tableName).ToList <QPoolField>());
            }
            else if (inst.GetType() == typeof(QAddColumnToTableCR) || inst.GetType() == typeof(QAddColumnToViewCR))
            {
                string tableName = (string)context.Instance.GetType().GetProperty("TableName").GetValue(context.Instance, null);
                return(fields.Where(p => p.TableName == tableName).ToList <QPoolField>());
            }
            return(fields);
        }