I have a project in UWP where I need to display the same text in a RichEditBox and in a RichTextBlock.
For some fonts (e.g. Courier), this is pretty ok and no big problems, but for other fonts (like Arial) the difference is pretty substantial.
Please note that I use exactly the same code, the only difference is just the Font.
Please find an MVCE that reproduces the issue here: https://github.com/vfailla/UWPRichEditBox
How can I setup the two elements to display the text in Arial in the very same visual way?
For some fonts (e.g. Courier), this is pretty ok and no big problems, but for other fonts (like Arial) the difference is pretty substantial. Please note that I use exactly the same code, the only difference is just the Font.
First of all, you will need to set the same CharacterSpacing of these two different controls:
m_richEditBox.CharacterSpacing = 100;
m_richTextBlock.CharacterSpacing = 100;
Then, you will need to set the same FontStretch of two controls, but here comes the issue:After a few tests I found textStretch doesn't work for RichEditBox/TextBox. And by default, the text inside look more like FontStretch.Condensed. So as a temporary workaround, you can set your RichTextBlock.FontStretch to FontStretch.Condensed:
m_richTextBlock.FontStretch = FontStretch.Condensed;
I'll consult through internal channel to report this issue, and I'll update this thread once I got any response.
Related
I have a textBox that grows vertically while typing. Unfortunately when I type a long text (for example a 3 line text) some PART of it gets blurry. What's more, when I prevent it from growing vertically and make it grow horizontally it works fine - the text is sharp then.
What I've tried:
UseLayoutRounding = true;
RenderOptions.TextRenderingMode = "ClearType";
Please forget about
TextOptions.TextFormattingMode = "Display"
It has to be "Ideal".
See the screenshots:
Disable SubPixel Rendering and Anti-Aliasing. Try
SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
Since you mentioned:
I have a textBox that grows vertically while typing
I assume then that it's a CustomControl derived from TextBox and with a custom rendering to grow vertically instead of using the builtin text wrap ability.
Since I was unable to reproduce your issue with the stock TextBox and the parameters (with Ideal) you mentioned (I've checked from Framework 4.0 to 4.6 on VS 2013), maybe the blur comes from your custom code.
By the way, with not using the builtin wrap?
TextWrapping="Wrap"
Maybe you should include more code and details, like framework version, visual studio version, OS version and so on.
Likewise, specify your version of "Textbox that grows vertically". Something like this ?
Try increasing the font size of the textbox just a tiny amount (use 1/4s if in pixels). Alternatively, try changing the line height slightly in a similar fashion. I think the problem might be down to WPF's interpretation of the sub-pixels and may be rounding off at the wrong place.
Am using Devexpress Winforms 12.2 version. I designed XtraReport with Logo on right side. When image is small automatically it align to left. I need to set pull right. Their is no option to set alignment in property. How to write programmatically code in BeforePrint event of xrPictureBox ?
I tried this one but didn't work xrPictureBox1.Image = ContentAlignment.MiddleRight; showing error cannot implicitly convert type ContentAlignment to Drawing.Image
Thanks in Advance.
You'd better search their support channel, there are several threads on this subject, like XTraReport - XRPictureBox alignment and XRPictureBox - Provide the capability to specify image alignment. From the last one looks like they finally provided out of the box solution XRPictureBox.ImageAlignment Property, but you need to upgrade to v15.1. If you can't, check if some of the suggested workarounds in the links work for you.
I am trying to perform edit functions in a RichTextBox on a C# (Windows Forms) application.
I would like to be able to select any number of text characters in the script then change targeted font characteristics.
The trouble I have is that each characters font properties may be set to different font. In this case the textbox ignores the event that I request.
How can I solve my problem?
Take a look at this:
Changing font for richtextbox without losing formatting
I think it's the same issue. LarsTech's solution is working perfectly for me.
I have a code to change the size:
RichTextBox1.Font.Size == new System.Drawing.Font(RichTextBox1.Font.Name, yoursize)
And if you want to change only the selected text size:
RichTextBox1.SelectionFont.Size == new System.Drawing.Font(RichTextBox1.SelectionFont.Name, yoursize)
Hope it will help.
First of all, I've looked at EVERY other post here, about this (I think) and none of them solves it.
I have a graph in excel, where I would like to change the colour of the line. It seems like, everything in the series line settings, is out of reach. If I cannot set the colour, I would like to set the fill to none, so the line is invisible, only showing the markers, which I can manipulate.
However, fill is also in the colour settings.
I have tried recording a macro aswell, but it shows nothing, other than series select.
Other posts here, suggest setting border on the series, but there is no border object to my knowledge.
Does anyone have any tricks that might solve this?
So, over on the MSDN forums, Andrei Smolin managed to solve it for me.
It was indeed Series.Border that fixed it.
The big problem was, that Border does not show up, as an object on series. Not even in VBA.
It seems to be fixed in Excel 2010, but this is the behaviour i'm experiencing in 2007 SP3.
So, the solution was to simply type:
MSExcel.Series Series1 = (MSExcel.Series)Chart.SeriesCollection(1);
Series1.Border.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.FromArgb(79, 129, 189));
which compiled fine, and worked at runtime.
For reference sake, this is the MSDN thread:
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/2816660e-a18e-47f4-b121-02a71cb2c262
In addition to Nicolai's answer, there is an easier way to pass color value to Border.Color, for example:
Series1.Border.Color = (int) XlRgbColor.rgbRed;
For Excel 2007, the following:
series5.Interior.Color = Color.FromArgb(80, 208, 146).ToArgb();
works for me.
For our winforms application, we've been asked to colour invalid cells in a DataGridView in a red colour. We need to find a red colour that matches the current visual style but which is still distinctive if the user has chosen a palette with mostly reds. How do I create a colour that will match the current visual style? How do I make sure I avoid clashes?
I don't think the original poster is looking to make a palette of colors (colours), instead he is trying to highlight an invalid cell. The chosen highlight color is red, but he is concerned that red might not stick out if the user has chosen a red palette.
How about this: When painting an invalid cell, use SystemColors.Window for the text and SystemColors.WindowText for the background. (or whatever equivalents there are for a DataGridView). This way, you are guaranteed that the invalid cell will be the opposite colors of a normal cell.
I think that you are looking at this the wrong way. Red is often chosen for several reasons. It is (in western culture among others) commonly used to depict that something is wrong or danger. But red is also a colour that usually stands out. However, when trying to direct a users attention to something on the page, there are two infallible methods.
1) Animated gifs or videos (annoying as f***) or
2) Clashing colours
Usually red stands out, but in your situation where a user may have a red themed style, your best bet is to go with a colour that will clash. It is possible to have clashing colours that go together (if that makes sense).
Here are a few websites that I have used in the past to help me find colour schemes that may help you as well:
Kuler, Color Combos and Color scheme designer
This may not have been the answer you were looking for but i hope it helps
The question is a bit ambiguous and a little subjective; it much easier to comment directly on examples. However, there are a multitude of on-line tools that will help you create colour palettes for websites, and these may be useful to gauge how a particular shade of red interacts with various other colours.
Hope this helps.
You could maybe try to use the Light and Dark methods of the ControlPaint class? I do something similar, although kind of in the opposite direction. I needed to make some rows in a grid stand out, but not stand out as much as the selected rows. So I created a color that was a bit lighter than the default selection color like this:
checkedColor = ControlPaint.Light(grid.DefaultCellStyle.SelectionBackColor, 1.65f);
Could try to use that, maybe with some added logic, and base it on some system color that is made to stand out. For example System.Drawing.SystemColors.HighLight or System.Drawing.SystemColors.HotTrack.
take a look at the Krypton Toolkit (http://www.componentfactory.com). They offer a free toolkit for WinForms controls with a theme manager. This theme manager provides ready to use methods to extract the current color values.
I have nothing to do with them. I use it for my own Product (Royal TS at http://www.code4ward.net) and found it really useful.
If you want to build beautiful UI, you should take a look at the Krypton stuff.