コード例 #1
0
        private void addAreaNameColumn()
        {
            DataGridViewCellFormattingEventHandler handler = null;

            if (Variable.sLogListAreaVisible.Equals("1", StringComparison.OrdinalIgnoreCase))
            {
                this.dgvLogData.Columns["区域"].Visible = true;
                if (handler == null)
                {
                    handler = delegate(object sender1, DataGridViewCellFormattingEventArgs e1)
                    {
                        try
                        {
                            if ((((e1.RowIndex >= 0) && (e1.ColumnIndex >= 0)) && ((e1.Value != null) && this.dgvLogData.Rows[e1.RowIndex].Cells["区域"].ColumnIndex.Equals(e1.ColumnIndex))) && MainForm.myCarList.tvList.hasCarPath.ContainsKey(e1.Value))
                            {
                                e1.Value = (MainForm.myCarList.tvList.hasCarPath[e1.Value] as ThreeStateTreeNode).CarAreaName;
                            }
                        }
                        catch
                        {
                        }
                    };
                }
                this.dgvLogData.CellFormatting += handler;
            }
        }
コード例 #2
0
 public ExtendedDataGridView()
     : base()
 {
     KeyDown += new KeyEventHandler(ExtendedDataGridView_KeyDown);
     CellContextMenuStripNeeded += new DataGridViewCellContextMenuStripNeededEventHandler(ExtendedDataGridView_CellContextMenuStripNeeded);
     CellFormatting             += new DataGridViewCellFormattingEventHandler(ExtendedDataGridView_CellFormatting);
 }
コード例 #3
0
        public DataGridViewNew() : base()
        {
            SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            MultiSelect           = false;
            RowHeadersVisible     = false;
            AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.Fill;
            AllowUserToAddRows    = false;
            AllowUserToDeleteRows = false;
            AllowUserToResizeRows = false;
            ReadOnly = true;
            RowHeadersWidthSizeMode     = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
            ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            BackgroundColor             = Color.FromArgb(0, 0, 64);
            BorderStyle      = BorderStyle.None;
            CellBorderStyle  = DataGridViewCellBorderStyle.None;
            RowsAdded       += new DataGridViewRowsAddedEventHandler(rowAdded);
            CellFormatting  += new DataGridViewCellFormattingEventHandler(getDescriptionCellFormatting);
            CellDoubleClick += DataGridView_CellDoubleClick;
            RowsDefaultCellStyle.SelectionBackColor = Color.Tomato;
            Sorted             += new EventHandler(columnsSortChanged);
            RowTemplate.Height  = 35;
            ColumnHeadersHeight = 35;
            MouseClick         += dataGridView1_MouseClick;
            menu.ItemClicked   += new ToolStripItemClickedEventHandler(menu_Clicked);
        }
コード例 #4
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// datagridviewcellformattingeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this DataGridViewCellFormattingEventHandler datagridviewcellformattingeventhandler, Object sender, DataGridViewCellFormattingEventArgs e, AsyncCallback callback)
        {
            if (datagridviewcellformattingeventhandler == null)
            {
                throw new ArgumentNullException("datagridviewcellformattingeventhandler");
            }

            return(datagridviewcellformattingeventhandler.BeginInvoke(sender, e, callback, null));
        }
コード例 #5
0
        public void Initialize()
        {
            SString  = Translator.TranslateStr(571);
            SInteger = Translator.TranslateStr(556);
            SDouble  = Translator.TranslateStr(556);
            data     = new DataSet();

            AutoGenerateColumns = false;
            SkipReadOnly        = true;
            ColumnCount         = 0;
            Columns.Add(new DataGridViewTextBoxColumn());
            Columns.Add(new ObjectInspectorColumn());
            EnterAsTab            = false;
            ColLabel              = Columns[0];
            ColProperty           = Columns[1];
            ColProperty.Resizable = DataGridViewTriState.False;
            ColLabel.Frozen       = true;
            ColLabel.ReadOnly     = true;
            ColLabel.DefaultCellStyle.BackColor = SystemColors.ButtonFace;
            ColLabel.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            ColProperty.AutoSizeMode            = DataGridViewAutoSizeColumnMode.None;
            ColLabel.AutoSizeMode                  = DataGridViewAutoSizeColumnMode.None;
            ColLabel.DataPropertyName              = "NAME";
            ColProperty.DataPropertyName           = "VALUE";
            ColProperty.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            AllowUserToOrderColumns                = false;
            AllowUserToResizeRows                  = false;
            AllowUserToAddRows     = false;
            AllowUserToDeleteRows  = false;
            this.SelectionMode     = DataGridViewSelectionMode.FullRowSelect;
            this.EditMode          = DataGridViewEditMode.EditOnEnter;
            this.RowHeadersVisible = false;
            this.MultiSelect       = false;

            ColLabel.SortMode    = DataGridViewColumnSortMode.NotSortable;
            ColProperty.SortMode = DataGridViewColumnSortMode.NotSortable;

            ColProperty.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            CellFormatting          += new DataGridViewCellFormattingEventHandler(FormatCell);


            AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
//            Font = new Font(Font.FontFamily, 6);
            int nheight = (int)Math.Round(Font.Size * 1.4 * (double)WinFormsGraphics.ScreenDPI() / (double)72);

            nheight = nheight + 5;
            if (nheight < 10)
            {
                nheight = nheight + 2;
            }
            RowTemplate.Height = nheight;
        }
コード例 #6
0
 private void setUpHandlers()
 {
     DefaultValuesNeeded   += new DataGridViewRowEventHandler(FormattedGridView_DefaultValuesNeeded);
     CellValidating        += new DataGridViewCellValidatingEventHandler(FormattedGridView_CellValidating);
     this.RowEnter         += new DataGridViewCellEventHandler(FormattedGridView_RowEnter);
     this.CausesValidation  = true;
     UserAddedRow          += new DataGridViewRowEventHandler(displayArrayGrid_DoubleClick2);
     CellEnter             += new DataGridViewCellEventHandler(FormattedGridView_CellEnter);
     CellFormatting        += new DataGridViewCellFormattingEventHandler(FormattedGridView_CellFormatting);
     EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(FormattedGridView_EditingControlShowing);
     this.RowsRemoved      += new DataGridViewRowsRemovedEventHandler(FormattedGridView_RowsRemoved);
     CellBeginEdit         += new DataGridViewCellCancelEventHandler(FormattedGridView_CellBeginEdit);
 }
        void Init ()
        {
            AutoGenerateColumns = false;

            MouseDown += new System.Windows.Forms.MouseEventHandler ( this.OnMouseDown );
            CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler ( this.OnCellDBClick );
            CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler ( this.OnCellContentClick );
            CellClick += new System.Windows.Forms.DataGridViewCellEventHandler ( this.OnCellClick );
            ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler ( OnClickColumnHeader );  //作废。列表排序不在这里实现。而是在 FindList 类中,通过 fl.SortBindingList() 来实现。DataGridView类自身自带了排序功能,只需要传入有排序属性的数据就可以了。
            CellFormatting += new DataGridViewCellFormattingEventHandler(OnCellFormatting); //在显示数据的同时,对Cell里的数据/颜色/字体等进行处理。不必再使用AfterFill()之类的函数了。
            
            ClearContextMenu () ;

            //ListViewColumnSorter sortHelper = new ListViewColumnSorter();
            //Sort( sortHelper );
        }
コード例 #8
0
        public MediaItemDataGridView()
        {
            CellFormatting += new DataGridViewCellFormattingEventHandler(MediaItemDataGridView_CellFormatting);

            smallImageList  = new ImageList();
            musicImage      = Resources.music;
            pictureImage    = Resources.picture;
            bookImage       = Resources.book_open;
            filmImage       = Resources.film;
            televisionImage = Resources.television;

            smallImageList.Images.Add(musicImage);
            smallImageList.Images.Add(pictureImage);
            smallImageList.Images.Add(bookImage);
            smallImageList.Images.Add(filmImage);
            smallImageList.Images.Add(televisionImage);
        }