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.
Unfortunately, activation email could not send to your email. Please try again.

Need extra layout call

Thread ID:

Created:

Updated:

Platform:

Replies:

15086 Jun 10,2004 01:56 PM Jun 10,2004 02:37 PM Windows Forms 3
loading
Tags: GridControl
Pete Davis
Asked On June 10, 2004 01:56 PM

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.

Administrator [Syncfusion]
Replied On June 10, 2004 02:08 PM

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.

Administrator [Syncfusion]
Replied On June 10, 2004 02:08 PM

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

Pete Davis
Replied On June 10, 2004 02:37 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;