Re: Problem drawing the right font in an owner draw TreeView



Thanks for the pointer. Rather than build another user control to handle
editing, I side stepped the issue by doing this:
During owner draw, I ignore the width of the passed in bounds rectangle.
Instead, I get the parent tree view's right edge and use that to generate a
DrawString rectangle. I also set the draw string's format value so that it
doesn't clip or wrap. The two togehter allow my own text to draw without
being clipped or trying to wrap.
I don't explicitly make the display font the same as the edit font. These
are allowed to be different. However, I do catch the before edit event and
use that to make sure that the TreeNode's display text is removed from the
screen, thus removing the stale text scraps that would otherwise be
displayed on the row at the same time that the smaller edit window is
active.

Again, thanks for the ideas.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Peter Ritchie [C# MVP]" <PRSoCo@xxxxxxxxxxxxxxxxx> wrote in message
news:9838BEA0-655B-47F1-8B85-032A8A4B3CA2@xxxxxxxxxxxxxxxx
If you're already using the font, that means the underlying Windows
control
that .NET uses doesn't support changing the font for the edit box.

You would have to handle the BeforeLabelEdit, set the
NodeLabelEditEventArgs.CancelEdit to false and do whatever you want for
editing...

I think this example does something like that:
http://www.codeproject.com/cs/miscctrl/CustomizedLabelEdit.asp?df=100&forumid=224195&exp=0&select=1952320

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


"Richard Lewis Haggard" wrote:

And what font would that be? I'm already using the one that is associated
with control itself and that is where my confusion is coming from in that
there appears to be a discrepancy between the font that is supplied by
the
control and the one that is used by the in place edit.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
"Peter Ritchie [C# MVP]" <PRSoCo@xxxxxxxxxxxxxxxxx> wrote in message
news:0F589954-D778-44DD-8FAB-508740764925@xxxxxxxxxxxxxxxx
Have you tried setting the ListView's Font property to the font you
want
the
text box to use when it displays?

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


"Richard Lewis Haggard" wrote:

I have a TreeView control that is marked as DrawMode: OwnerDrawText
and
has
inline LabelEdit set to true. The problem is that the text that I'm
getting
from the node to draw is not the same font that is being used by the
edit
or
the same font that is being used by inline editing. When I do the
DrawString, I'm using the font that is in the node so it is unclear to
me
why the node's text is too big to fit in its bounds or why the
displayed
text is larger than the same text in the node's inline edit box.
Ideas?







.



Relevant Pages

  • Re: programmatically initialize properties of dialog controls
    ... for font I couldn't manage without specifying font name. ... concatenating in edit box - it just occurred to me that all the same I ... >>First make sure that you have attached a variable to any control that you ... > or check boxes, you can create value variables which you initialize before ...
    (microsoft.public.vc.mfc)
  • Re: Reduce character spacing in an edit or rich edit control?
    ... I would like to use SetTextCharacterExtra on an edit or rich ... > edit control so that the text may be squished together. ... At least you have the option to draw each character separately. ... HDC provide by WM_CTLCOLOREDIT to an font you create. ...
    (microsoft.public.vc.mfc)
  • Re: CEdit problem
    ... you will want to set the font of the edit control to the font you desire. ... I believe there is a codeproject example that has a dynamically-resizing edit control. ...
    (microsoft.public.vc.mfc)
  • Replace Format?
    ... Press Ctrl+H, or Edit> Replace. ... move to the Replace with: control and enter ... then, click on the Format button, select Font and then ...
    (microsoft.public.word.newusers)
  • Re: Changing Font of button in EditCommandColumn on Datagrid
    ... > through the controls collection in the ItemCreated Event, changing the font ... Another option would be to apply a CSS class to the EditCommandColumn's ... control in the ItemDataBound or ItemCreated events. ... to edit the code and recompile. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)