Search code examples
c#winformstelerikradgridradgridview

Application hangs/freezes when setting RadGridView datasource


I have one winforms app and when I minimize the window I need that the processes still running. It's all ok until i set the RadGrid datasource : radGrid1.DataSource = datasource1; When I set the datasource this way the app just freezes and nothing happens more. After some search I've modified the code to: radGrid1.BeginUpdate(); radGrid1.DataSource = datasource1; and this way I can set the data source but my grid loses the format. If I add the radGrid1.EndUpdate() it freezes too.

What can I do do load the datasource and don't lose the format of my radgrid?

Best regards


Solution

  • From the telerik docs:

    To prevent the grid from traversing all data fields in that collection, set the GridViewTemplate.AutoGenerateColumns property to False. In this case, the additional fields that you might use when sorting, grouping, etc., should be included in the MasterGridViewTemplate.Columns collection. With these settings, only the properties that are used as column FieldName properties or those specified in the MasterGridViewTemplate.Columns will be extracted.

    Should fix the problem you described with "losing the format". Second problem, the program freezing, is not something I've encountered in the numerous of occasions I've worked with RadGridViews in windows forms environments.

    The only thing I can think of is that your datasource collection is too large, or items in the collection have too many fields that the RadGridView is trying to generate columns for when the AutoGenerateColumns property is set to true.