Adding an image in a picture box Windows Form - c#

I created a windows form to display text in a richtext and then added a picture box to add some color to it. at the moment when I load up the form it looks like this:
The dot above the rich text is the location of were I added the picture box, at the moment when I try to add an image to picture box it gives me an error: Value cannot be null. Parameter name: docData. I get this error by going to the properties of the picture box and to Image witch is labled (none) at the moment.
How do I fix this problem that I am having. (I use C# 2010 Express, XNA Game Studio 4.0, Windows Game(4.0))

This seems to be a Windows Game (4.0) issue. See the answer on this page. You could try to set the image in your code like this:
pictureBox1.Image = Image.FromFile("path/somefile.jpg");
According to this page, this problem is a bug that hasn't been fixed.

Related

Crystal Report showing Poor quality Text Preview

I am using Crystal report v13.0.4000.0 in my windows forms application in VS2019.
My Problem: Crystal report preview shows Pixelated poor-quality text at runtime. I'm wondering is it just like that OR is there any workaround for that. I have seen SSRS and RDLC
they show crystal clear text in the preview at runtime. Here are images for comparison:
Picture 1 : Preview at runtime
Picture 2 : Preview when viewing Crystal report viewer in VS2019 !
enter image description here
Both images are from the same VS2019 Project.
If anybody knows about this or even has an idea please share your thoughts.
Note : Above images contain truly Text Field. Printer report is Crisp and clear the problem is with the preview only why cant I get picture 2nd image quality in the preview.
Crystal renders content to the screen based on the capabilities of the default (or specified printer).
So Make sure the default/specified printer is capable, and that the printer driver is patched/recent.
Please clarify: are these truly text or are they images you are displaying inside Crystal?
If they are images, test the effect of setting the viewer's property of InterpolationMode to Drawing2D.InterpolationMode.HighQualityBicubic

c# picturebox size changing from display option being set to 125%

I have a form with a picturebox in it. I have to set the picture box to stretch image( I don't care if it changes the resolution of the picture) and I load the picture at runtime. Then I want to put buttons on the picture and I read these locations from a file and these locations change depend on which picture is loaded. All works good on my laptop but I do not account for the fact under display you can make text and other items larger. This laptop is set to 125%. What do I use to scale my points or can I just turn this off for my program? I would prefer to just turn it off. It changes my splash screen too.
I am using Visual Studio, C#
I found the answer to my problem. When I would load my VS project on a machine that was set to 125% it would actually change the size of my controls inside my project. If you do not want visual studio to change the size of these control you have to set display text and images to 100%, load your VS project, add autoscalemode = none, then close the project, change display text and images back to 125% then all should be good.

DrawToBitmap returns black Image from UserControl

My first post here so here goes,
i have a UserControl with about 30 controls (labels, textboxes etc).
Now i would like to make a "screenshot" of it.
So i used the "DrawToBitmap" method from the UserControl.
Here some samplecode
//this is the UserControl with the about 30 controls
var sampleusercontrol = new SampleUserControl();
var bmp = new Bitmap(sampleusercontrol.Width, sampleusercontrol.Height);
sampleusercontrol.DrawToBitmap(bmp, sampleusercontrol.Bounds);
if i run this code, it returns me a black image all the time.
I have no clue why. Please help!
Edit:
Forgot to say that the UserControl is a WinForms UserControl
This had been working for me for years until it started returning a black image last week in production. Interestingly, it was just after we applied a new windows patch. I was able to find this posting about the issue:
KB3057839 Has Broken Windows Forms Control.DrawToBitmap() When Called from Application Launched From Windows Service
You didn't mention how that winforms control was being created, but in the first case it was from a winforms app launched by a service. There is also a case on the Telerik site where the control was instantiated server-side by IIS to create a PDF file:
http://www.telerik.com/forums/export-to-pdf-597e04c01b39
Try checking for the patch KB3057839 and rolling it back for a short term fix. Hopefully Microsoft will respond with a fix or a workaround going forward.
I had the same issue. The latest round of ms patches corrected the issue.
Check that the control has been loaded.
I was struggling with this, but it turned out the control was in another tab and wouldnt display correctly until I had clicked on the tab, then run DrawToBitmap.

Copying an image within my Windows Phone App

I am writing a Windows Phone Application in C# and on my application page i have an image object that is currently filled with an image. However i have another image object on the same page as well as a button object. What i want to do it click the button, and once i have done so i want to copy the image from the filled image object and paste it into the blank object.
Is there a way of doing this, i read something about the use of a bitmap to do so but i'm not sure how to do it? Any examples or ideas of what code i could use would be greatly appreciated.
You can remember Image.Source and pass that to the other page and set it as a source for another image control.
It also depends on how you are filling the first Image control. If you are in the control of filling both controls, then you can just as easy use the same code to fill both controls.

Picture Box, Image loading

Adding the Windows Form template to my full game as a way to read a text file when ever its called. I add a picture box to the form and what comes up is Value cannot be null. Parameter name: docData I looked around the Interwebs and it seems to be a problem with XNA (4.0) and how its missing things that make picture box work. How do I work around this to add a image to the picture box?
I will start from the beginning. I create a Windows Game(4.0), name it PictureBox. I add the Windows Form, name that Form1.cs. I add in the picture box. I then open up the properties menu, click on Image and it gives me the null. I have done nothing yet, but still this error happens.

Categories