We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridDataBoundGrid.ResizeToFit question/issue

I have a GDBG that I''m trying to make work with the ResizeToFit functionality... I have been doing the following after I bind a dataview to the grid... _searchEventsDG.DataSource = _data.eventView; this._searchEventsDG.Binder.InternalColumns["AllTix"].HeaderText = "All Tix"; this._searchEventsDG.Binder.InternalColumns["YourTix"].HeaderText = "Your Tix"; this._searchEventsDG.Model.Cols.Hidden["ID"] = true; this._searchEventsDG.Model.Cols.Hidden["P1"] = true; this._searchEventsDG.Model.Cols.Hidden["P2"] = true; this._searchEventsDG.Model.Cols.Hidden["PType"] = true; this._searchEventsDG.ActivateCurrentCellBehavior = GridCellActivateAction.None; My data is updated once per minute so this doesn''t run extremely frequently... I tried adding this line to the end of it, and when I do it causes crashing and other bugs where my app stops responding... this._searchEventsDG.Model.ColWidths.ResizeToFit(GridRangeInfo.Table()); what am I doing wrong?

4 Replies

AD Administrator Syncfusion Team May 30, 2005 08:11 PM UTC

Are you using multiple threads? If so, are you using a grid.InvokeRequired check to make sure the call to grid.model.Cols.ResizeToFit is being done on the thread that created the grid? If you run your application in the debugger and set the debugger to break on exceptions, what call stack do you get with teh exception?


AD Administrator Syncfusion Team May 30, 2005 09:24 PM UTC

the function that does the binding of the dataview is in the same thread, well the function that is being called is... I know this because I ran into that same issue and had to use methodinvoke from another thread to get the databinding portion working aswell... is there something I have to do to the ResizeToFit function call or to the grid to correct this?


AD Administrator Syncfusion Team May 30, 2005 10:31 PM UTC

Right before you call this._searchEventsDG.Model.ColWidths.ResizeToFit(GridRangeInfo.Table()); try adding this code:
if(this._searchEventsDG.InvokeRequired())
{
   throw new Exception("Wrong Thread");
}
to check whether the call is on the wrong thread. Are you seeing any other exceptions? These are abount the only thing I can think of that would cause such behavior, a threading problem, or unhandled exceptions that are prventing the standard behavior of the code.


AD Administrator Syncfusion Team May 30, 2005 10:42 PM UTC

Ya your right it''s saying its on the wrong thread... guess I''ll need to make a method invoke for this seperately from the other thread... sorry about that... thanks for the help

Loader.
Live Chat Icon For mobile
Up arrow icon