Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to add image on window form?

I’m trying to add an image on window form using c#, but every implementation did not give the result I needed. I want the image stay on the navigation bar, but it always hop into the main tab. This is the code I’m currently using

public TabPage AddCustomTabs()
{
    TabPage imageTab = new TabPage();
    imageTab.Text = "";
    PictureBox pictureBox = new PictureBox();
    pictureBox.Image = Image.FromFile(@"gameBarResources\kakumei.png");
    pictureBox.Dock = DockStyle.Fill;

    // Add the picture box to the tab page
    imageTab.Controls.Add(pictureBox);

    // Add the tab page to the tab control
    _tabControl.TabPages.Add(imageTab);

    return imageTab;
}

window form image
The image supposed to be at the navigation bar (The pink area)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

  1. Add an ImageList to your form and add it images. Set the image size.
  2. Set the TabControl’s ImageList property to your image list (e.g. imageList1).
  3. Click on a tab page and set the ImageIndex or the ImageKey property. There is a drop-down in the properties window, where you can select an image from the ImageList.

You can also change the ItemSize of the TabControl. This defines the size of the tabs (navigation part of the tab page).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading