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.

Show/Hide controls

Thread ID:

Created:

Updated:

Platform:

Replies:

34484 Sep 9,2005 01:57 PM Sep 19,2005 01:28 PM Windows Forms 8
loading
Tags: GridControl
Madhavi Balusu
Asked On September 9, 2005 01:57 PM

Hi, You probably answered this million times, but I don''t have the time to look around, so... What is a good place(s) for me to Show/Hide my custom control in a grid? Right now I am doing it in Renderer''s OnDraw and that is giving me a lot of problems.. 1) When the user "enters" the cell ( click/tab/Setting Focus in the code etc), I need to show the control with the right size ( cell''s size). 2) Conversely, commit and hide the above shown control when the user "leaves" the cell... Short deadline, please advise.

Administrator [Syncfusion]
Replied On September 12, 2005 07:17 AM

Hi Monica, Renderer.OnDraw is the correct method to set the controls size / visibility. Try calling the base class only when the cell is in focus to see if that serves your purpose. Here is the code I tried in the Windows\Grid.Windows\samples\CellTypes\CalendarCells sample. protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) { clientRectangle.Size = GridUtil.Max(clientRectangle.Size, CalendarCellModel.CalendarControlSize); if (this.ShouldDrawFocused(rowIndex, colIndex)) { style.Control = editCalendar; base.OnDraw (g, clientRectangle, rowIndex, colIndex, style); } Best regards, Jay N

Madhavi Balusu
Replied On September 12, 2005 08:33 PM

OnDraw is not working for me. It is a very busy call. Would OnBeginEdit/OnEndEdit work?

Administrator [Syncfusion]
Replied On September 13, 2005 07:26 AM

Hi Monica, When the grid needs to calculate CellLayout in the OnDraw, it gets the clientrectangle from Renderer.OnLayout. So you could try this, instead of setting the size in OnDraw, return the desired size by overriding OnLayout to see if that helps. protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { Rectangle r = base.OnLayout (rowIndex, colIndex, style, innerBounds, buttonsBounds); // Onlayout for other cells if (!this.ShouldDrawFocused(rowIndex, colIndex)) return new Rectangle(r.X, r.Y, 0, 0); else //for CurrentCell return r; } Best regards, Jay N

Madhavi Balusu
Replied On September 14, 2005 04:10 PM

Thanks Jay. That is exactly what I am doing. So my control sizes fine, but what about init/commit my control from/to the grid? For this purpose would OnBeginEdit/OnEndEdit do? There seem to be a lot of calls that could be used during committing the values *from* the customcontrol *to* the grid: OnSaveChanges/OnValidating/OnDeactivating etc..But the question is what is the "right" call to commit the values?

Administrator [Syncfusion]
Replied On September 15, 2005 07:45 AM

Hi Monica, Please try initializing your control in OnInitialize override and save the changes from control to the Grid in OnSaveChanges override. protected override void OnInitialize(int rowIndex, int colIndex) { } protected override bool OnSaveChanges() { } Windows\Grid.Windows\samples\CellTypes\SliderCells is a good sample to see the implementation. Best regards, Jay N

Madhavi Balusu
Replied On September 16, 2005 02:58 PM

Weird Behaviors: My grid is wired to GridTextBoxCellRenderer. What does it mean when: 1) the Renderer''s OnInitialize is called with CurrentCell.IsEditing = true;? Should''nt it be false? This is happening with only 1 grid, other grids it is set to false. 2) For some reason in the renderer call, the current cell is getting unwired with the renderer, i.e. this.CurrentCell.Renderer = null; Looking at your code, I figured I had to do: SetPositionNoActivate ( in Onlayout) But the question is why did my currentcell''s renderer become null in the first place. Thanks.

Administrator [Syncfusion]
Replied On September 19, 2005 07:38 AM

Hi Monica, Is it possible to post a sample showing the problem? It would help us to analyze the issue better. Thanks, Jay N

Madhavi Balusu
Replied On September 19, 2005 01:28 PM

No, don''t have that kind of time. I worked around the IsEditing problem using CancelEdit(). My only concern is if I am masking a bigger problem by these working around with above mentioned calls.

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.

;