Exemple #1
0
        public TestForm()
        {
            InitializeComponent();

            // Columns
            var Column1 = new Column("String")
            {
                ValueGetter = (item) => ((TestItem)item).Name,
                ValueSetter = (item, value) => ((TestItem)item).Name = value.ToString(),
                CellEditor  = new TextCellEditor(),
                Width       = 215,
                HeaderFont  = new Font(dList1.HeaderFont, FontStyle.Bold | FontStyle.Italic),
                ItemFont    = new Font(dList1.Font, FontStyle.Italic)
            };

            var Column2 = new Column("Numeric")
            {
                ValueGetter  = (item) => ((TestItem)item).NumericValue,
                CellRenderer = new ProgressBarCellRenderer(0, 100)
            };

            var Column3 = new Column("Boolean")
            {
                Width              = 150,
                ValueGetter        = (item) => ((TestItem)item).Flag,
                ValueSetter        = (item, value) => ((TestItem)item).Flag = (bool)value,
                CellRenderer       = new CheckBoxCellRenderer(),
                CellEditor         = new BooleanCellEditor(),
                CellColorEvaluator = (value) => ((bool)value) ? (Color.Black, Color.Green) : (Color.Black, Color.Red)
            };

            var Column4 = new Column("DateTime")
            {
                ValueGetter = (item) => ((TestItem)item).Date,
                ValueSetter = (item, value) => ((TestItem)item).Date = (DateTime)value,
                CellEditor  = new DateTimeCellEditor()
            };

            var Temp = (TextCellRenderer)Column4.CellRenderer;

            Temp.Format = "{0:F}";

            dList1.Columns.Add(Column1);
            dList1.Columns.Add(Column2);
            dList1.Columns.Add(Column3);
            dList1.Columns.Add(Column4);

            dList1.ItemColorEvaluator = (item) => (((TestItem)item).NumericValue > 50) ? (Color.Black, Color.Gold) : (Color.Empty, Color.Empty);

            // Progressbar test items
            var PTestItem0 = TestItem.GenerateRandomItem(0);

            PTestItem0.NumericValue = 0;
            var PTestItem1 = TestItem.GenerateRandomItem(1);

            PTestItem1.NumericValue = 50;
            var PTestItem2 = TestItem.GenerateRandomItem(2);

            PTestItem2.NumericValue = 100;

            dList1.Items.Add(PTestItem0);
            dList1.Items.Add(PTestItem1);
            dList1.Items.Add(PTestItem2);

            // Completely random items
            var Items = TestItem.GenerateRandomItems(17, 3);

            dList1.Items.AddRange(Items);

            int MaxItemIndex = dList1.Items.Count - 1;

            numericUpDownItemIndex.Maximum       = MaxItemIndex;
            numericUpDownItemIndex2.Maximum      = MaxItemIndex;
            numericUpDownSelectRangeFrom.Maximum = MaxItemIndex;
            numericUpDownSelectRangeTo.Maximum   = MaxItemIndex;

            numericUpDownColumnIndex.Maximum = dList1.Columns.Count - 1;

            dList1.Items.CollectionChanged  += CollectionChangedOrChanging;
            dList1.Items.CollectionChanging += CollectionChangedOrChanging;
            dList1.Items.ItemChanged        += ItemChanged;

            dList1.Columns.CollectionChanged  += CollectionChangedOrChanging;
            dList1.Columns.CollectionChanging += CollectionChangedOrChanging;
            dList1.Columns.ItemChanged        += ItemChanged;

            dList1.SelectedItemIndices.CollectionChanged  += CollectionChangedOrChanging;
            dList1.SelectedItemIndices.CollectionChanging += CollectionChangedOrChanging;
        }
Exemple #2
0
 public static void Init()
 {
     CheckBoxRenderer.InitRenderer();
     LabelRenderer.InitRenderer();
     CheckBoxCellRenderer.Init();
 }