this.gridControl1.ColWidths[2] = 200;
GridStyleInfo style = this.gridControl1[2,2];
style.CellType = "ComboBox";
style.DataSource = dt;
style.DisplayMember = "Col1";
style.ValueMember = "Col1";
style.BorderMargins.Right = 25;
style.BorderMargins.Left = 25;
To change the width of the dropdown itself, you have to handle the CurrentCellShowingDropDown event and set the e.Size.
private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; if(cc.ColIndex == 2 && cc.RowIndex == 2) { e.Size = new Size(150, e.Size.Height); } }
> this.gridControl1.ColWidths[2] = 200;
> GridStyleInfo style = this.gridControl1[2,2];
> style.CellType = "ComboBox";
> style.DataSource = dt;
> style.DisplayMember = "Col1";
> style.ValueMember = "Col1";
>
> style.BorderMargins.Right = 25;
> style.BorderMargins.Left = 25;
>
>
> To change the width of the dropdown itself, you have to handle the CurrentCellShowingDropDown event and set the e.Size.
> > private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) > { > GridCurrentCell cc = this.gridControl1.CurrentCell; > if(cc.ColIndex == 2 && cc.RowIndex == 2) > { > e.Size = new Size(150, e.Size.Height); > } > } >
style.BackColor = Color.Red;
Then in a CellDrawn event (requires version 1.6 maybe ??), color the rectangles on either end to be the color you want them to be.
private void gridControl1_CellDrawn(object sender, GridDrawCellEventArgs e) { if(e.RowIndex == 2 && e.ColIndex == 2) { Rectangle rect = e.Bounds; rect = new Rectangle(rect.Left, rect.Top, 25 , rect.Height ); e.Graphics.FillRectangle(Brushes.LightPink, rect); rect = e.Bounds; rect = new Rectangle(rect.Right - 25, rect.Top, 25, rect.Height ); e.Graphics.FillRectangle(Brushes.LightPink, rect); } }
> style.BackColor = Color.Red;
>
>
> Then in a CellDrawn event (requires version 1.6 maybe ??), color the rectangles on either end to be the color you want them to be.
> > private void gridControl1_CellDrawn(object sender, GridDrawCellEventArgs e) > { > if(e.RowIndex == 2 && e.ColIndex == 2) > { > Rectangle rect = e.Bounds; > rect = new Rectangle(rect.Left, rect.Top, 25 , rect.Height ); > e.Graphics.FillRectangle(Brushes.LightPink, rect); > > rect = e.Bounds; > rect = new Rectangle(rect.Right - 25, rect.Top, 25, rect.Height ); > e.Graphics.FillRectangle(Brushes.LightPink, rect); > } > } >
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
So, if you need to test for say the cell style to do certain actions (say checking the bordermargins in CellDrawn to know whether to draw the border rectangles), then you can just do it without having to maintain a list. If you really need to track additional information that is not part of the style, you could actually add it to the style using the style.Tag property. Then you would have access to it in these events as well.