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.
AD
Administrator
Syncfusion Team
September 12, 2005 11:17 AM UTC
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
MB
Madhavi Balusu
September 13, 2005 12:33 AM UTC
OnDraw is not working for me. It is a very busy call.
Would OnBeginEdit/OnEndEdit work?
AD
Administrator
Syncfusion Team
September 13, 2005 11:26 AM UTC
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
MB
Madhavi Balusu
September 14, 2005 08:10 PM UTC
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?
AD
Administrator
Syncfusion Team
September 15, 2005 11:45 AM UTC
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
MB
Madhavi Balusu
September 16, 2005 06:58 PM UTC
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.
AD
Administrator
Syncfusion Team
September 19, 2005 11:38 AM UTC
Hi Monica,
Is it possible to post a sample showing the problem? It would help us to analyze the issue better.
Thanks,
Jay N
MB
Madhavi Balusu
September 19, 2005 05:28 PM UTC
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.