Code Red > .NET

Modify tablestyle - get grid color

(1/1)

latour_g:
Hi,

I'm struggling getting the actual color grid of a tablestyle.

Here is how I do it :


--- Code - C++: ---DBDictionary tabS = (DBDictionary)tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForWrite); foreach (DBDictionaryEntry dbEntry in tabS){         TableStyle tabStyle = (TableStyle)tr.GetObject(dbEntry.Value, OpenMode.ForWrite);          string cCol_inner_title = tabStyle.GridColor(GridLineType.InnerGridLines, RowType.TitleRow).ColorIndex.ToString();         string cCol_inner_header = tabStyle.GridColor(GridLineType.InnerGridLines, RowType.HeaderRow).ColorIndex.ToString();         string cCol_inner_row = tabStyle.GridColor(GridLineType.InnerGridLines, RowType.DataRow).ColorIndex.ToString();          // and so on for AllGridLines, OuterGridLines, HorizontalBottom, HorizontalGridLines...} 
It always return color 0, however I have put red everywhere.

Thank you !

n.yuan:

--- Quote from: latour_g on June 02, 2021, 10:08:28 AM ---...
It always return color 0, however I have put red everywhere.

Thank you !

--- End quote ---

When you say "...have put red everywhere...", do you mean you make the grid line red of an ACTUAL TABLE, or a Table Style, which you as user do not see it directly, but only see its preview in Table Style editing dialog box? Not sure which case you are in.

If it is former, then you should check table itself by its GridColor() method, not its TableStyle's GridColor() method. A table inherits many of its properties from TableStyle, but can overwrite the properties on its own.

latour_g:
Hi,

It's the tablestyle that has the red grid line. 

n.yuan:
Well, setting table/tableStyle gridline color is quite complicated. The first argument GridLineType of the GridColor() method by no means makes things any easier, rather it makes thing much more difficult, because the gridline types may overlap each other. In this regard, I'd prefer the same corresponding method in COM API (GetGridColor()), where are only 7 GridLineTypes there, as opposed to 12 in .NET/ObjectARX (with overlapped types).

To test actual gridline color, it would depend on whether the grid line is visible or not, which is done with SetGridVisibility() method. This only makes things even more difficult, depending on the region of cells (or whole row/rows, column/columns!!!): whether it is on top, bottom, adjacent to other cell region... So, the table style editing dialog box use a series of button to let user to select the border(gridline) is visible or not. When you set a grid color, you need to first click the last button to make sure no border is visible, and then select color, then click the button(s) to make border shown as desired.

The attached picture shows what I chose to show the title row's border in red.

and this code to test the title row gridline color:


--- Code: ---        [CommandMethod("TSTes")]
        public static void TestTableStyleGridLineColor()
        {
            var dwg = CadApp.DocumentManager.MdiActiveDocument;

            using (var tran = dwg.TransactionManager.StartTransaction())
            {
                var tsDict = (DBDictionary)tran.GetObject(dwg.Database.TableStyleDictionaryId, OpenMode.ForRead);
                var tStyle = (TableStyle)tran.GetObject(tsDict.GetAt("STANDARD"), OpenMode.ForRead);

                var titleColor1 = tStyle.GridColor(GridLineType.InnerGridLines, RowType.TitleRow).ToString(); //ByBlock
                var titleColor2 = tStyle.GridColor(GridLineType.HorizontalGridLines, RowType.TitleRow).ToString(); //ByBlock
                var titleColor3 = tStyle.GridColor(GridLineType.OuterGridLines, RowType.TitleRow);  //ByBlock
                var titleColor4 = tStyle.GridColor(GridLineType.HorizontalTop, RowType.TitleRow);  // This color is RED
                var titleColor5 = tStyle.GridColor(GridLineType.HorizontalGridLines, RowType.TitleRow);  //ByBlock
                var titleColor6 = tStyle.GridColor(GridLineType.HorizontalInside, RowType.TitleRow);  //This color is RED


                tran.Commit();
            }

        }

--- End code ---

Hope this helps.


latour_g:
Well it work with your code !

I don't understanding why the same thing in .NET/ObjectARX is not working but I will use COM API then !

Thank you ! :-)

Navigation

[0] Message Index

Go to full version