What I want is change the font size in a text view to fit all of content onto the page while being as large as possible. The text in it is also changing in length so just testing won't work. I also don't want it to have to scroll, but it is a multiline text view. This is in C# and I can't list anything I've tried because I am unsure as to where I should start.
Related
My program has several Label controls that are updated to have different text every so often. I have a few icons that I want to reference within the text. I figured that instead of just displaying "(E)" in the Label, there should be a way to replace that with the corresponding image that I have that looks like: . I figure that I need to override the Label.Paint event, but I'm not too sure how to do that properly. Every occurrence of "(E)" needs to be replaced with the image inline.
Example
Look for the (E) icon on the top. → Look for the icon on the top.
This is not a trivial exercise.
You'd have to provide a property on your derived label class to attach the image(s) to the text.
Embed some sort of token(s) in the text to represent the image(s).
In the OnPaint you have to parse the text for the token(s)
Do a graphics.MeasureString() for each bit of text between the tokens. And then render it with graphics.DrawString() move to the right by the width of the text, render the image based on the token using one of the many graphics.DrawImage() overrides - move to the right by the width of the image and repeat.
We have a case where we need to display Character Ellipsis(i.e. show text as trimmed) when we have multiline text.
The textblock shows trailing ellipsis when the content is anyway bigger than the width of the multiline TextBlock (i.e. TextWrapping is set to Wrap).
But we have a case wherein, we need to show only one line with ellipsis whether the text width of the first line is greater than the width of textblock or not.
For example, consider the following sample text
String str = "1\n2\n3456\n45889";
textBlock.Text = str;
The TextBlock should display as shown below:
1...
and the ToolTip will show the entire text. I tried doing some research on the possibilities but could not find much help and was wondering if anyone in the community has encountered such a situation or perhaps could suggest me?
Since, we shouldn't change the underlying data object (real time scenario) but only change what is rendered to the user, I am guessing a Converter should do the trick but I am still stuck on how to proceed. Or do you guys have any other alternatives?
Create a custom control based off of the textblock which handles the business logic needed for the ellipse.
The binding of the actual text to a specific property can ensure that the text is not changed. While in a separate property you have the visual text with the ellipse which gets updated when the original text changes (the dependency property change event) and the visual text subsequently displayed on the screen. Also have the tooltip bound to the original text which helps in that scenario of showing the actual text and not the ellipsed text.
By creating an easy custom control you have the ability to handle the business logic all in one location and it can be used in other screens and projects.
I have a web browser in my win form
I'm filling it's content with some text for each time(text size in each loop almost the same size).
my web browser size is fixed
i want to aromatically fix my content text to browser content
(for example if my content text size is more than the web browser content with some algorithm fix it to content and do not show scroll)
exactly some algorithm that fix Css for each content size to web browser size
is it possible?(may be some thing like change text size for best fix or ...)
all you really need to do it wrap your text inside some DIV tag, and this will auto encapsulate the text in your DIV to fit the window.
I'm assuming you do not want the horizontal scroll bar, is that correct? Because you haven't specified, I'm just guessing. If it is the vertical scroll bar you do not want, then let me know.
Otherwise, if you're text input is being placed in many different areas, and you really need more global or generalized control over this, you can alter the WIDTH attribute in your BODY tag to ensure it is exactly, or a few pixels smaller than the width of your WebBrowser control.
So if your WB control width is 600, you would place this in your BODY tag of the HTML page you have loaded (i'm assuming you have access to the HTML page, if not, once again, let me know).
<BODY WIDTH="590">
Let me know how you go, and if I've totally missed or misunderstood your question, please let me know and add the details necessary so that we can understand what you need.
Cheers.
Working on a WinForms .Net 2.0 project, I need a checkbox to support multiple lines such that the box itself will be aligned to the top-left corner.
This is done using CheckAlign = System.Drawing.ContentAlignment.TopLeft, which different from the default (MiddleLeft).
When working with the default font this looks OK, but when the font becomes larger - what happens is that the gap above the text increases, yet the gap above the box itself remains constant.
The result is that the box appears above the text (see illustration below).
Any ideas?
I'd like to note that:
I already tried a few option, such as using a custom designer, a TableLayoutPanel, etc., but didn't get far.
.Net 2.0 is forced - upgrading is not an option.
Thanks in advance.
The checkbox is actually aligned to the text. But in a way that could only please a typographer. It is just that a large font has more ascender height, the space where the diacritics go. Try "Ĥere's the problem". That's not something you can tinker. CheckedListBox also doesn't support owner draw, it is in general a pretty flawed control. If you don't want to use an ownerdraw ListBox then MiddleLeft or smaller fonts are the only decent options.
I am creating a program that's for use with touchscreens. Everything has to be quite big for usability.
At some point I realized some controls (groupbox with flowpanel inside which contains buttons) had to move inside a tabcontrol to make better use of the resolution we have. Everything went fine until I changed the font size of the tabcontrol's headers. When I change the header font size to a bigger font size (20) all the content grows too. With the content I mean everything. Everything the tabcontrol contains grows along with the header font size. I really don't know what to do here. Is this a bug or what's going on?
I have also tried to change the font size in code, with the same result.
Is there anyone who had the same experience? Or anyone who can reproduce this problem?
SxMT
Your tab control is probably scaling because of font change. See this
TabControl -> UserControl -> GroupBox
The problem was that when I changed the font size of the TabControl the font size for all children changed. I had changed the font size for the group box manually but that didn't solve the problem. I had to change font size of the User Control itself instead of the content of the User Control so that it didn't resize.
This is quite confusing because the User Control didn't contain any text directly. Changing the font size of the User Control affects the font size of the children, changing the font size of the children directly didn't.