C1FlexGrid programmatically mark columns visible - false

Posted by: jay on 26 May 2020, 7:44 am EST

    • Post Options:
    • Link

    Posted 26 May 2020, 7:44 am EST

    Data table rows are loading into the FlexGrid when AutoGenerate is turned on.

    I want to turn off autogenerate so that I can hide a few columns (mark as not visible) but when I do so the grid loads empty. I have manually entered the columns with the data source for each column from the select statement.

    Is there a way to mark the columns as visible false in the code directly? Not seeing anything relevant for hiding columns in documentation, examples, or forums aside from within the control itself.

    Public Sub BindLists()
    
        Using con As New SqlConnection(constring)
          Using cmd As New SqlCommand("SELECT ItemName, ItemValue FROM CIWLists WHERE ListName='Manager' ORDER BY ItemName", con)
            con.Open()
            Dim dt As New DataTable()
    
            dt.Load(cmd.ExecuteReader())
    
            With Me.ManagerComboBox
              .DisplayMember = "ItemName"
              .ValueMember = "ItemValue"
              .DataSource = dt
            End With
    
            Dim R As DataRow = dt.NewRow
            R("ItemName") = "All"
            R("ItemValue") = "All"
            dt.Rows.InsertAt(R, 0)
    
            ManagerComboBox.SelectedIndex = 0
    
            Using cmd2 As New SqlCommand("SELECT T1.[id],'B'+ T1.[bg_job_number] AS JobNumber
          ,T1.[job_name] AS JobName
    			,ISNULL(T3.[ProjectNotes],'') AS ProjectNotes
    			,ISNULL(T3.ID,0) AS ProgressID
      FROM [CIW_intranet].[dbo].[big_jobs] T1
    	LEFT JOIN (SELECT * FROM [CIW_intranet].[dbo].[ProjectProgress]) T3
    	ON (T1.[id] = T3.[ProjectID]) AND (T3.[JobNum] = T1.[bg_job_number])
    	WHERE (T1.[status] = 0 AND T1.JobType != 0) AND ([manager] LIKE '%%')
    	UNION 
    SELECT T2.[id]
    			,'S' + T2.[sm_job] AS JobNumber
    			,T2.[company] AS JobName
    			,T4.[ProjectNotes]
    			,ISNULL(T4.ID,0) AS ProgressID
    	FROM [CIW_intranet].[dbo].[small_jobs_old] T2
    	LEFT JOIN (SELECT * FROM [CIW_intranet].[dbo].[ProjectProgress]) T4
    	ON (T2.[id] = T4.[ProjectID]) AND (T4.[JobNum] = T2.[sm_job])
    	WHERE (T2.[complete] = 0 AND T2.[JobType] != 0) AND ([manager] LIKE '%%')
    	ORDER BY JobNumber", con)
              Dim dtlist As New DataTable()
    
              C1FlexGrid1.DataSource = dtlist
    
              dtlist.Load(cmd2.ExecuteReader())
    
              con.Close()
            End Using
          End Using
        End Using
      End Sub
    
  • Posted 26 May 2020, 6:04 pm EST

    Hi Jay,

    >>Is there a way to mark the columns as visible false in the code directly?

    You can use the Visible property of the RowCol class of FlexGrid to set the visibility of the specified column as given in code snippet below:

    grid.Cols["Col_Name"].Visible = false;
    
    

    https://www.grapecity.com/componentone/docs/win/online-flexgrid/C1.Win.C1FlexGrid.4.5.2~C1.Win.C1FlexGrid.RowCol~Visible.html?highlight=visible%2C

    I hope it helps. If you have any further queries then please let us know.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels