Different Fonts in one Label

混江龙づ霸主 提交于 2019-12-22 10:53:13

问题


does anybody know a way how to create a Label(WindowsForms) with two different Fonts or at least two different FontSizes?


回答1:


I think you should override default label onPaint method and draw multiple text/fonts manually using Graphics.
Take a look at this example.




回答2:


Try to override or handle paint event (method) use classes from System.Drawing namespace.




回答3:


You have to create your own drawing using GDI also try to find out if you can find any other third party controls that support your need !! Hopefully you might get them.




回答4:


you can do that things with usercontrol wpf first of all from add item search usercontrol and after that in the xml of builder name grid like t1 and in the code of it type this code

    StringBuilder sb = new StringBuilder();
    sb.Append(@"<TextBlock   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
                    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> ");
    sb.Append(@"  Hello <Bold>my</Bold> faithful <Underline>computer</Underline>.<Italic>You rock!</Italic>");
    sb.Append(@"</TextBlock> ");
    TextBlock myButton = (TextBlock)XamlReader.Parse(sb.ToString());
    t1.Children.Add(myButton);

and run it and change it in a new manner.



来源:https://stackoverflow.com/questions/7358654/different-fonts-in-one-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!