C# Winforms Datagridview font is getting bolded when scaling to 150% - c#

I've got a datagridview which displays information and also has some input columns. When using 100%, 125% and 175% resolution, the texts looks normal and is not thick. (image example 1). When changing to 150%, the headers and the text of the datagridview gets this strange bold and I can't seem to figure out why. Any suggestions? Thank you !
Example #1 (this is how it looks on 100%
Example #2 : this is where it gets bolded.
When scaling to 150%, the rest of the text in the form looks normal, and I use the same font in the form as well as in the datagridview.
Example #3
Example #4
I tried setting the CellStyle (header/general) to null, making the font smaller and still no results.

Related

Infragistics UltraTextEditor changes font in Edit mode

I have a Infragistics UltraTextEditor (v.18.2): I set the font property to "Consolas", "10pts" both in the "Appearance" and in the "Font" sections of the control's properties.
The UltraTextEditor displays correctly (i.e. with my font properties) its content, but when I edit the content, font is set to 9pts, which seems to be it's default. I (and my users) would like the font to stay set at 10pts, of course. Is there something I am missing?
Thanks in advance to anyone who will help
The quick answer is that you can avoid this by doing one of two things:
Set the UltraTextBox property of AlwaysInEditMode = True
Set the UltraTextBox property of TextRemderingMode = GDI
The change in spacing (between edit and non-edit mode) is caused by the underlying .NET TextBox, which was created before GDI+. .NET uses GDI+ as it's native mechanism for drawing and the UltraTextBox uses GDI+ when displaying the UltraTextBox in non-edit mode. When entering edit mode, the drawing mechanism changes to the old GDI, which causes a difference in spacing.
Credit: Infragistics Community Forum

C# RichTextBox how to change font ForegroundColor upon printing?

I'm trying to use the RichTextBox (that I've modified a bit with some additions found here and there) so that when I print, my white text becomes black.
To be more precise, I have a RichTextBox with a PrintDocument, PrintPreviewDialog, and so on. I can print without problem with this setup. The only thing is that my application has a dark theme (it is made to be used mainly by night) and the RichTextBox has a black background and the default text is white.
Therefore, when I print (or preview), the white text stays white and it can't be seen when printed...
I would then like to know how I would need to modify my components to change the font color from white to black upon printing. I do not care about other colors (they are the assumed choice of the user) that will be printed fine anyway.
Thanks so much for your pointers on this!
Put this code in your print handler,
var selection = myRichTextBox.Selection;
if (!selection.IsEmpty)
richTextBox1.SelectionColor = Color.Black;

Adding image to rtf doc being resized

We're using migradoc api to create an rtf document.. intermittently when we add an image it;s being resized and coming out absolutely tiny.
Code sample as follows:
MigraDoc.DocumentObjectModel.Shapes.Image image = section.AddImage(imagePath);
image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;
If I set LockAspectRatio to true and set a width it does stop is from rendering very small but ideally would like to be able to set a MaxWidth.
Has anyone experiences similar issue?
You have a choice of either changing the image itself by storing a different DPI value in it.
The .Net command to do so with a Bitmap bmp is:
bmp.SetResolution(newHRes , newVRes);
This should not involve reencoding, but I'm not sure.
However you also can simply set the desired DPI value in the Migradoc Image by using its Image.Resolution Property, which
Gets or sets a user defined resolution for the image in dots per inch.
I am not familiar with it at all but I found this code that might help you :
image.RelativeVertical = RelativeVertical.Page;
image.RelativeHorizontal = RelativeHorizontal.Page;

Changing Column Height for ListView Column

With reference to my previous question here: Changing Font Size for ListView Column in C#. I would like to know how to change the height of the column within a listView with OwnerDraw enabled.
I have succeeded in changing the font using the following code.
using (Font headerFont =
new Font("Helvetica", 10, FontStyle.Bold)) //Font size!!!!
{
e.Graphics.DrawString(e.Header.Text, headerFont,
Brushes.Black, e.Bounds, sf);
}
Although I cannot change the size of the column, giving it a cut-off effect. I have been playing around with the Rectangle.Bounds property but this appears to be read only.
Any suggestions?
Thanks
I have decided to take an alternative approach for my application. I chose to remove the header altogether and replace it with labels within a Container Panel.
This was achieved by changing the HeaderStyle property of the listView to "None". The result allowed me to dock the labels to the top of my listView, giving me the larger text I've been after!
Granted this is a little different to the question asked but provides a simple solution to what appears to be a complex problem! Additionally this would make the column headers static so may not be useful for developing applications requiring numerous changes
Thanks for all your help, and let me know if you would like more detail
Euan
You can try Better ListView Express. It allows changing column header height to arbitrary sizes. It is also free and the usage is 99% same as ListView.

Weird glitch with ASP.net drawing

I have a code that draws a few things. At the end, it draws a string. The string looks like it was copied from a text editor -- really nice! But weirdly, when I try to draw exactly same image only 10 pixels wider, the text gets blurry. When I say wider, I only mean like initializing a Bitmap with +10px width. Image still draws on the same area like those 10px were not there.
I already checked measureString. It seems fine. My first thought was that it measures wrong and shrink text width but that can't be case since I'm only passing text and font to measureString.
I already tried drawing the text then copying the whole Image to a new Bitmap only 10px wider (Image again stays the same width, the 10px are just blank space) but exactly same thing happens. I have way too much code to post it all. Any suggestions as to what could be the problem?
Example:
Thanks
You most probably forgot about a late-on width constraint which is keeping your final picture from expanding in width correctly: in your "resized" sample the drawn text is being shrunk, so logic (and the proportionally wider whitespace to the right of the "resized" sample) suggests you're actually trying to fit a wider picture in the same area.

Categories