Hello!
I would like to remove the description text in front of the AddButton (UltraGrid.DisplayLayout.AddNewBox.Prompt="") and simply use the Caption on the AddButton (UltraGrid.DisplayLayout.Bands(0).AddButtonCaption="MyCaption").
When I do like this, the Button ends up all the way to the left in the addnewarea, withput any padding whatsoever... I looks like rubbish to be honest ;-)
Before, I used a small peace of text and then I made the AddNewBox.Appearance.Forecolor into white which was the background color of this area. it then came invisible and things looked good. Not I am using AppStyling and Office2007black and that doesn't work for me any longer.
Anyone that has an idea of what to do...?
Thanks for your help!
/Henrik
Have you tried setting the Prompt to some space characters, rather than an empty string?
Yes, I have tried that without success... Blanks were my first though... ;-)
Hi,
Sorry, that was a bad suggestion. Setting the ForeColor will not work, since it just gets overriden by the isl file.
You will need to use a DrawFilter. In this case, it's a pretty simple one:
public class AddNewBoxHiddenCaption_DrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { return true; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is DependentTextUIElement && drawParams.Element.Parent is AddNewBoxUIElement) { return DrawPhase.BeforeDrawForeground; } return DrawPhase.None; } #endregion }
Hello Mike!
Thanks for the code. I have implemented to code in my project (except for the *region* thing) . unfortunately I am not sure how to use this since I haven't used any drawfilters before. I am not sure what they do...
What I did was the following: (in the initializelayout event of the form)
ug.DrawFilter = df (ug ismy ultra
I suppose that you will have to explain this a bit more for me to understand... sorry for that ...
The code you have here looks fine to me. Are you saying this is not working?
Maybe InitializeLayout is too late. Try using Form_Load.
It works, even if I use InitializeLayout. I missed to set a character instead of a null string as AddNewBox.Prompt. Sorry for that...
Before we close this thread, could you please write a few lines explaining what this code really does? I haven't been working with drawfilters before and i suppose that this code in some way or another cancels the draw operation for the addnewbox prompt text...
thanks for a good solution!
/henrik
Hi Henrik,
Sorry about that, I should have commented the code the first time. :)
public class AddNewBoxHiddenCaption_DrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // We should only get in here for a DependentTextUIElement that is a child of an // AddNewBoxUIElement - because that's what GetPhasesToFilter is returning. // Just to be safe, we could do some sanity checks here. // if (drawParams.Element is DependentTextUIElement == false) { Debug.Fail("DrawElement is firing for an element that is not a DependentTextUIElement; unexpected."); return false; } if (drawParams.Element.Parent is AddNewBoxUIElement == false) { Debug.Fail("DrawElement is firing for an element that is not a child of the AddNewBoxUIElement; unexpected."); return false; } switch (drawPhase) { case DrawPhase.BeforeDrawForeground: // Return true to indicate to the grid that the drawing of the foreground for this // element has already been handled. The grid will not draw any foreground, and // since we did not draw anything, either, the foreground drawing is effectively // cancelled. // return true; default: // GetPhasesToFilter never returns any other phase besides BeforeDrawForeground. So // we should never get here. Debug.Fail("DrawElement is firing for a pahse other than BeforeDrawForeground; unexpected."); break; } // Do nothing. return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { // Look for a DependentTextUIElement that is a child of the AddNewBoxUIElement. // This is the element that draws the AddNewBox caption. // if (drawParams.Element is DependentTextUIElement && drawParams.Element.Parent is AddNewBoxUIElement) { // Fire the BeforeDrawForeGround phase. return DrawPhase.BeforeDrawForeground; } // Do nothing. return DrawPhase.None; } #endregion }