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

Need extra layout call

I''m having a timing issue on my layout and I''m not quite sure when would be the best time to call PerformLayout for this particular case. As I said earlier, I''ve got a grid derived from the GridControl. My grid uses shared scrollbars. It''s also a virtual grid. I have properties (protected) in my derived grid: ShowVScroll and ShowHScroll. If the scrollbars are set for Automatic, then I only display them if they need to be displayed. In OnLayout(), I call get the ShowVScroll (or ShowHScroll) value (a boolean) to decide if I need to display my scrollbars. The check in ShowVScroll that''s problematic looks like this: if ((this.VScrollBehavior & GridScrollbarMode.Automatic) > 0 && this.RowCount <= this.ViewLayout.VisibleRows) { return false; } The problem is the "this.RowCount <= this.ViewLayout.VisibleRows" The last time PerformLayout is called, this condition is not met because this.RowCount = 10 (the default?) and this.ViewLayout.VisibleRows has a value of either 3 or 5 at the time. So, my scrollbar gets shown though it really shouldn''t (there are only 4 rows, including the column headers, and the grid is plenty tall to show them). It appears that the RowCount hasn''t been updated by the time this is called. If, after it''s displayed, I double-click on the grid (I suppose this causes a call to OnLayout()), I get the proper layout because the values are correct So as I said, it appears to be a timing issue. I guess I need to call PerformLayout() at some point, but I''m not sure when. Thanks.

3 Replies

AD Administrator Syncfusion Team June 10, 2004 06:08 PM UTC

Before you get into this code, you could try calling grid.ResetVolatileData. That should take care of the RowCount reflecting the proper values provided you have your data available and QueryRowCount subscribed to when this ResetVolatileData call is made. One other comment is that grid.UpdateScrollBars is that call the grid uses to make sure the scrollbars reflect things properly. I am not whether you could make use of this call as well.

AD Administrator Syncfusion Team June 10, 2004 06:08 PM UTC

Hi Pete, some ideas would be to listen to the parent forms Load event (FindForm will return the parent) and try it there. Or even do it the first time OnPaint is called. You could wire yourself to the parent Forms Load event when the controls InitLayout method is called (that happens when the grid is added to the Parent controls Controls collection). /// protected override void InitLayout() { base.InitLayout (); if (parentForm == null) { parentForm = this.FindForm(); if (parentForm != null) parentForm.Load += new EventHandler(f_Load); } } Hope this helps. Stefan

PD Pete Davis June 10, 2004 06:37 PM UTC

Clay and Stefan, It''s possible the UpdateScrollBars() or even the ResetVolatileData() would do what I need if it were called at the right time, but I couldn''t find a time that gave me the correct effect. Fortunately, calling PerformLayout on the parent form load event was sucessful. Thanks for the idea Stefan. Thanks to both of you for your help. Pete

Live Chat Icon For mobile
Up arrow icon