Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
problem with initializelayout
posted

I have a grid that i am filling with a dataset. I fill the from a SQL query on the backgroundworker DoWork. then in RunWorkerCompleted i set the ultragrid1.datasource = myDataset. this works fine but the initializelayout does not have an effect on the grid. i put a breakpoint in there and it is definitly running, but it is not effecting the grid. for example, i want to hide a couple  columns, but they still are displayed. But if i dont use the UltraGrid1.InitializLayout Sub, then it works fine and hids the columns and changes some other display properties. is there a bug?? any help i appreciate it, thanks

Parents
No Data
Reply
  • 2677
    posted

    Hello,

     I am not sure what is going on with the application.  I set up a similar scenario to test this and was not able to reproduce the problem.  I have a button that calls BackgroundWorker1.RunWorkerAsync(). 

    Then in DoWork, I fill a DataTable with some infomration. 

    Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            dt = TestData()
        End Sub 

    Then in RunWorkerComplete, I set the DataSource of the grid to that DataTable. 

     Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
            UltraGrid1.DataSource = dt
        End Sub

    Then the InitializeLayout is fired and I hide two columns using the hidden property.

    Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
            e.Layout.Bands(0).Columns(0).Hidden = True
            e.Layout.Bands(0).Columns(1).Hidden = True
        End Sub

     When the grid is rendered, the two columns are hidden.  Try the sample code below at your end to see if it works or not.  If it does not, please contact Developer Support and provide them the information and they should be able to diagnose your problem.  I am not sure what version of the controls that you are using, so I can't test and know for sure whether this is an issue with the application or the infragistics control itself.  Hope this helps

    Here is the complete code.  All I have on the form is the Ultragrid, a button, and a backgroundworker.

    Public Class Form1
        Dim dt As DataTable
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            BackgroundWorker1.RunWorkerAsync()
        End Sub

        Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
            e.Layout.Bands(0).Columns(0).Hidden = True
            e.Layout.Bands(0).Columns(1).Hidden = True
        End Sub

        Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            dt = TestData()
        End Sub

        Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
            UltraGrid1.DataSource = dt
        End Sub
        Function TestData()
            Dim NumberOfRecords As Integer = 10
            Dim dtData As New DataTable

            dtData.Columns.Add("Column_1", GetType(Object))

            dtData.Columns.Add("Column_2", GetType(String))

            dtData.Columns.Add("Column_3", GetType(Integer))
            Dim i As Integer
            For i = 1 To NumberOfRecords
                Dim dr As DataRow
                dr = dtData.NewRow()
                dr(0) = "Col 1 Row " + i.ToString()
                dr(1) = "Some Text " + i.ToString()
                dr(2) = i
                dtData.Rows.Add(dr)
            Next

            Return dtData

        End Function

    End Class

Children
No Data