Hi all,
I derived my own control from UltraTextEditor to show an icon in the top left corner of the control (I overwrote OnPaint). PLs see attached image.
But when I now enter Edit Mode it draws the text box over my Icon. So I need to move the inner text box more to the right. How is this possible?
Or can I achieve this by doing it in a completely diffrent way, maybe DrawFilter ?
Regards
Michael
Hi Michael,
Using OnPaint is going to be problematic.
A CreationFilter would work better, because it would allow you to manipulate the UIElements and moving the text UIElement would also reposition the TextBox when the control enters edit mode.
But... it seems to me that there is a much simpler solution here. You could simply set the ultraTextEditor.Appearance.Image property to an image. The only problem I see with that approach is that you want the image in the top left instead of center left.
this.ultraTextEditor1.Appearance.Image = Image.FromFile("image file"); this.ultraTextEditor1.Appearance.ImageHAlign = Infragistics.Win.HAlign.Left; this.ultraTextEditor1.Appearance.ImageVAlign = Infragistics.Win.VAlign.Top;
This is a much simpler approach, so I can't see any reason why you would want to jump through hoops to use a CreationFilter or OnPaint. Unless the position of the image needs to be more precisely positioned - in which case I could probably whip you up a simple CreationFilter example.
Hi Mike,
thanks for your reply. I need to have it exactly positioned and additionally I need to be able to click on that icon and change it during runtime.
I would highly appreciate your example :-)
Thanks
I just want to verify 2 things before I create the sample:
1) Using my code, the image is literally about 1 or 2 pixels off from where you have it in your screen shot. So you are saying that's not acceptable for what you need? If not, then I can write you a CreationFilter that moves the image 1-2 pixels, but it seems like a lot overkill for something so tiny.
2) Detecting a click on the image is the same regardless of how you display the image. You do it using the UIElements. You could use MouseDown or MouseUp and I will whip up some sample code for that.
Even if you need to move the image, applying it to the Appearance is still a good idea, since that way the image element is already there and this will save a lot of coding. Otherwise, you have to create an manage your own ImageUIElement.
Here's the sample. It moves the image 3 pixels up and to the left and also shows how to capture a mouse click on it.
Hi Matthew,
Yes I finally checked it and its pointing me in the right direction.
Thanks a lot and thanks to Mike for the example.
Did you get a chance to look at the example?
sorry for the late reply, but I was already in the weekend.
Yes, I need it accurately positioned. Our designer insists on it :-)
Thanks for the example I will check it today.