Issues with displaying images

Hello, I'm pretty new to C# and have been working on a project for a while and I reached a big roadblock right as I was finishing it up.
Currently what I'm trying to add is a simple script that I'd launch using LPRun7, and I want it to open an image with a text overlay in a font of my choosing, then play a gif animation after a keypress, then return to the original image with the numbers in the text overlay advanced by 1.

The big issue though is I want this to display in a secondary window separate from my LinqPad 7 project window, and in the future I want it to display to a specific secondary monitor fullscreen with no border. And preferably I would like to have this be done after launching my script with LPRun7 through a batch file.

At first I was just trying to get anything to display in the results panel so I tried this script out:

var button = new System.Windows.Forms.Button { Text = "Hello, world!" };
PanelManager.DisplayControl (button, "My Button");

When done in this manner it works great in regular LinqPad7 which was hopeful as it was the first time I got graphics to display, though it seems like it's bound to the results panel and can't be separated, and when this script is run using LPRun7 I will instead get a black screen for a few seconds, then the window closes after quickly flashing an error on the screen that says something along the lines of "The name PanelManager does not exist in current context"

So, is it possible to both run a script using LPRun7 and have images displayed to a separate dedicated window (or possibly a specific secondary monitor) when the script is launched in this manner? I could settle for ditching the LPRun7 option but I really need the images to display in a separate window.

Any help at all would be appreciated, again I'm pretty new to this and I hope my rushed explanation isn't too confusing.


  • The output panels are part of the GUI and so don't exist when using LPRun. You must either use the LINQPad GUI, or create a Windows.Forms.Form (or a WPF window) and show that.

  • @JoeAlbahari said:
    The output panels are part of the GUI and so don't exist when using LPRun. You must either use the LINQPad GUI, or create a Windows.Forms.Form (or a WPF window) and show that.

    Thank you! That helped steer me in the right direction! I had some trouble at first still but saw a previous post where you recommended using new Form1().Show(); so that got a window to display but now I'm having issues displaying an image in it. I think I'm supposed to use PictureBox and have tried different bits of code from online and can't seem to get it working.

    Here's what I have currently:
    `new Form1().Show();
    public partial class Form1 : Form
    PictureBox picturebox1;

        public Form1()
        private void Form1_Load(object sender, EventArgs e)
            picturebox1 = new PictureBox();
            picturebox1.Name = "picturebox1";
            picturebox1.Location = new Point(0, 0);
            picturebox1.Size = new Size(817, 447);
            picturebox1.BorderStyle = BorderStyle.Fixed3D;
            picturebox1.Image = Image.FromFile(@"D:\bkg.png");

    This gives me an error saying "CS0103 The name 'InitializeComponent' does not exist in the current context" I'm not too sure what I could be doing wrong here, maybe I'm missing a reference or namespace import? This has been seemingly more complex than anything I've done so far and I can't find any code examples that work for me online, maybe there's another way of going about this?

  • edited October 30

    I am going to assume you pasted all of your Source Code which is inside of Linqpad...

    InitializeComponent is usually part of the automatically generated/defined code that is done while using the Visual Studio's Designer.

    Note the "partial class Form1" in code above where "partial" allows you to separate your class's source code across multiple source files ( which is how / why the designer and tools you use are able to auto generate and modify/edit your classes and magically merge/work )

    Many ways to get this to work depending on what tools you have access to but if you want something quick and dirty you can just manually create the InitializeComponent method (or just create an "init" same difference), move all the code from "Form1_Load" and put it into this method and just invoke this method from inside Form1's constructor ..
    hope this photo helps of a quick/ugly example of what I said above:

    This works

Sign In or Register to comment.