cancel
Showing results for 
Search instead for 
Did you mean: 

System Matrix Cell Read Only

Former Member
0 Kudos

Hi,

Is it possible to make just one cell of a row read only ?

also is it possible to change the color of that cell ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For versions before 8.81:

To "set" it read only I think is not possible. But you can work around, by blocking all events on that particular cell - it's not a very pretty workaround but will do what you need; block got_focus, click etc and basically the cursor can never enter that particular cell - downside, there is no visual signal for the user to indicate that it is read only.

For changing colour; it depends. If you mean the background or text colour, then unfortunately no. You can do another workaround where you add a picture column and change the picture file being used in that cell depending on the status you desire - obviously this is not what you are looking for, but I'm afraid it's the best I can suggest.

-


From 8.81 on you can:

Cells Configuration: In matrix and grid objects, you can now:

Set colors and fonts for rows, columns, and cells

Disable or enable cells

Set and get the focus of a specific cell (GetCellFocus and GetCellFocus methods of the Grid and Matrix objects)

Former Member
0 Kudos

Great. Thank you for the information.

Former Member
0 Kudos

I'm unable to find example of how to change the background color of a cell or to make it read only

in 8.81

Edited by: Marc Roussel on Jun 3, 2011 7:47 AM

Former Member
0 Kudos
SAPbouiCOM.CommonSetting setting = oMatrix.CommonSetting; 
 
// Set background color in matrix cells 
int redBackColor = Color.Red.R | (Color.Red.G << 😎 | (Color.Red.B << 16); 
 
// Set background color in row 
setting.SetRowBackColor(1, redBackColor); 
int blueBackColor = Color.Blue.R | (Color.Blue.G << 😎 | (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 << 😎 | (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 << 😎 | (newRGBColor.B << 16); 
setting.SetRowFontColor(2, rowForeColor); 
 
// Set foreground color in cell 
int yellowForeColor = Color.Yellow.R | (Color.Yellow.G << 😎 | (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);

Taken from helpfile Matrix Object- > CommonSetting

Former Member
0 Kudos

Thank you,

I tried by converting an Hexadecimal color in int still no back color change at the cell level which the line I tried is this

oMatrix.CommonSetting.SetCellBackColor(1, 1, HexToInt("FF0000"));

Edited by: Marc Roussel on Jun 3, 2011 9:00 AM

This isn't working too

oMatrix.CommonSetting.SetCellBackColor(1, 1, System.Drawing.Color.Blue.ToArgb());

Edited by: Marc Roussel on Jun 3, 2011 9:01 AM

I tried this and still the cell doesn'T change color

SAPbouiCOM.CommonSetting setting = oMatrix.CommonSetting;

int redBackColor = System.Drawing.Color.Red.R | (System.Drawing.Color.Red.G << 😎 | (System.Drawing.Color.Red.B << 16);

setting.SetCellBackColor(1, 1, redBackColor);

Oh now it works, The column I was taking which is 1 doesn't seem to be the right one I had to take column 3 to get the ItemCode color to change. However the ItemCode column number is 1 not 3 so I'm not sure what that means

Arrggg I tried column 4 and it doesn't seem to work so I don't understand what the Column must be for the SetCellBackColor as it's not what I think it is suppose to be

rasmuswulff_jensen
Active Contributor
0 Kudos

SAP Use OLE colors so in C# do this:

int color = System.Drawing.ColorTranslator.ToOle(Color.Red);

Also please not that the 8.81 color methods does not work on the UID of the cells but the order of the cells... Therefor if you have ColUid = "1" it is not the same as when you color column number 1 (that is determined on the order of the columns)

Former Member
0 Kudos

Ok I think I see what you mean. I have to go in the form settings to know what is the order of my column

I think this parameter for a developper point of view would have been easier to set the column as shown when we show information at the bottom

at least a constructor so you can choose which kind of parameter is best

Edited by: Marc Roussel on Jun 3, 2011 9:18 AM

Former Member
0 Kudos

A very big thank you to all. Everything works like a charm

Former Member
0 Kudos

Is there any reason why this doesn't give the right color ?

oMatrix.Columns.Item("U_KitSeq").BackColor = Color.Orange.ToArgb();

It gives a blue color...

I don't understand why the color must be set this way

int blueBackColor = Color.Blue.R | (Color.Blue.G << 😎 | (Color.Blue.B << 16);

?

Sorry Rasmus Wulff Je... already answered.

Edited by: Marc Roussel on Aug 24, 2011 10:26 AM

Former Member
0 Kudos

I'm looking for a better way to get the column for using SetCellBackColor as it needs the one in order or I'm not even sure but

also when I try to make the ItemCode not editable by this code, it gives the error Item - Item is not a user defined item

oMatrix.CommonSetting.SetCellEditable(iDetailRow, 3, false);

17 which is the order in which the Unit Price is, doesn't have it's color changed to Orange so I'm wondering why many things doesn't work the way it is supose to work

oMatrix.CommonSetting.SetCellBackColor(iKitRow, 17, GetColor(Color.Orange)); // Matrix is SAP Sales Order

Edited by: Marc Roussel on Aug 24, 2011 10:38 AM

Edited by: Marc Roussel on Aug 24, 2011 10:43 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

When i'm trying to set a row editable false on a system matrix the program display Item - the item is not a user-defined item is there any solution to this?