📚 SAP Business One SDK Help

CommonSetting Object
See Also  Members  Example

Description

Represents the common settings for cells or rows in a grid or matrix.

Remarks

In the Grid object, rows and columns start at 0, while in this object, rows and columns start at 1.

Example

Controlling Cell Color, Font, Cell Focus, and Editable (C#)Copy Code
SAPbouiCOM.CommonSetting setting = oMatrix.CommonSetting; 
 
// Set background color in matrix cells 
int redBackColor = Color.Red.R | (Color.Red.G << 8) | (Color.Red.B << 16); 
 
// Set background color in row 
setting.SetRowBackColor(1, redBackColor); 
int blueBackColor = Color.Blue.R | (Color.Blue.G << 8) | (Color.Blue.B << 16); 
 
// Set background color in cell 
setting.SetCellBackColor(1, 1, blueBackColor); 
int color = 0; 
 
// Get background color in cell 
color = setting.GetCellBackColor(1, 1); 
 
// Set foreground color in column 
col = oMatrix.Columns.Item(9); 
int greenForeColor = Color.Green.R | (Color.Green.G << 8) | (Color.Green.B << 16); 
col.ForeColor = greenForeColor; 
 
// Set foreground color in row 
Color newRGBColor = Color.FromArgb(100, 100, 200); 
int rowForeColor = newRGBColor.R | (newRGBColor.G << 8) | (newRGBColor.B << 16); 
setting.SetRowFontColor(2, rowForeColor); 
 
// Set foreground color in cell 
int yellowForeColor = Color.Yellow.R | (Color.Yellow.G << 8) | (Color.Yellow.B << 16); 
setting.SetCellFontColor(2, 9, yellowForeColor); 
 
// Get foreground color in cell 
color = setting.GetCellFontColor(2, 9); 
 
//Set font style in row 
col = oMatrix.Columns.Item(21); 
setting.SetRowFontStyle(3, SAPbouiCOM.BoFontStyle.fs_Italic); 
 
//Set font style in cell 
setting.SetCellFontStyle(3, 21, SAPbouiCOM.BoFontStyle.fs_Strikeout); 
 
//Get font style in cell 
SAPbouiCOM.BoFontStyle styler = setting.GetCellFontStyle(3, 21); 
col.TextStyle = (int)SAPbouiCOM.BoFontStyle.fs_Bold; 
 
//Set font size in row 
col = oMatrix.Columns.Item(13); 
setting.SetRowFontSize(4, 15); 
 
//Set font size in cell 
setting.SetCellFontSize(4, 13, 10); 
int fontSize = 0; 
 
//Get font size in cell 
fontSize = setting.GetCellFontSize(4, 13); 
col.FontSize = 20; 
 
//Set system focus 
oMatrix.SetCellFocus(1, 13); 
oMatrix.SetCellFocus(2, 20); 
 
//Get system focus 
SAPbouiCOM.ICellPosition oPos = oMatrix.GetCellFocus(); 
int rowNum = oPos.rowIndex; 
int colNum = oPos.ColumnIndex; 
 
//Set editable in row 
setting.SetRowEditable(2, false); 
col = oMatrix.Columns.Item(2); //Get second column 
col.Editable = false; 
 
//Set editable in cell 
setting.SetCellEditable(2, 3, true); 
col.Editable = true; 
 
//Get editable in cell 
bool res = true; 
res = setting.GetCellEditable(2, 3);

See Also