0

I have already tried: How to wrap header caption in Janus GridEx and https://www.c-sharpcorner.com/forums/table-column-set and looked through Janus documentation at http://codelibraries.blogspot.com/search/label/Janus%20GridEX.

I have a business requirement to show wrapped column header. For example, if column header is:

This is column header

need to show

This is column
header

As it is right now (before I tried implementing code for this requirement), code looked like:

        dgMulti.SetDataBinding(bulkTable, "")
        dgMulti.RetrieveStructure()

        Dim column As Janus.Windows.GridEX.GridEXColumn
        For Each column In dgMulti.RootTable.Columns
            column.Width = 150
        Next

where bulkTable is a System.Data.DataTable object.

After visiting above links, I tried suggestions and used ColumnSets as shown below and added after above code:

        Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
        CSET.Caption = "YourCaption"
        CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
        CSET.ColumnCount = 2
        CSET.Width = 150
        CSET.Key = "YourCaptionKey"
        ' FOLLOWING LINE THROW ERROR 
        **CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(0).Key, dgMulti.RootTable.Columns(0).ColumnType), 0, 1)
        CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(1).Key, dgMulti.RootTable.Columns(1).ColumnType), 0, 2)**
        dgMulti.RootTable.ColumnSets.Add(CSET)
        dgMulti.RootTable.ColumnSetHeaderLines = 2
        dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets

Error: Operation is not valid due to the current state of the object.

Can you please help what I am missing? I believe I need to somehow link the columns with ColumnSets but how?

Ahmar
  • 1
  • 1
  • I think the index should start with 0, try this : CSET.Add(GridEXColumn, 0 ,0) CSET.Add(GridEXColumn, 0 ,1) – Makesh Oct 08 '20 at 11:43

2 Answers2

0

You don't need columnsets for this. I can't get a deeplink to the janus forums thread with this answer, but here is the copy/pasted answer:

You can put a CR Character if you can determine where to wrap. in e.g.

Column.Caption = Now.ToString("ddd" & vbCr & "d MMM");

You can see the janus support forums here: https://www.janusys.com. Click through to the Winforms GridEX forum, and use search phrase "wrap". The website is basically unusable in Firefox, I fallback to Chrome to browse.

Phil Sayers
  • 193
  • 1
  • 7
0
Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
    CSET.Caption = "YourCaption"
    CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
    CSET.ColumnCount = 2
    CSET.Width = 150
    CSET.Key = "YourCaptionKey"
    dgMulti.RootTable.ColumnSets.Add(CSET)
    CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 0)
    CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 1)
    dgMulti.RootTable.ColumnSetHeaderLines = 2
    dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 06 '23 at 21:39