Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Control background color/image

Control background color/image

Scheduled Pinned Locked Moved C#
graphicscsharpwinformslinqtutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sandeep Kalra
    wrote on last edited by
    #1

    Hi All Look at the code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DealingWithImages { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.label1 = new System.Windows.Forms.Label(); this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(53, 52); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(211, 13); this.label1.TabIndex = 2; this.label1.Text = "This is windows forms do you like it?"; this.Controls.Add(label1); Image myimage = Image.FromFile(@"Give path of the image"); this.BackgroundImage = myimage; this.MaximumSize = new System.Drawing.Size(400, 400); this.MinimumSize = new System.Drawing.Size(400, 400); } protected override void OnMove(EventArgs e) { base.OnMove(e); this.Refresh(); this.Invalidate(); } protected override void OnPaintBackground(PaintEventArgs e) { if (this.BackgroundImage != null) { e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; e.Graphics.DrawImage(this.BackgroundImage, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height); } else { base.OnPaintBackground(e); } } } } I have to put image on the background of my windows form which I am doing using the code above. I have some controls which I am generating at runtime. Now the challenge is the background color of the control(here label1) looks odd on the form. Does anybody know How to solve it? Thanks Regards THE SK

    X 1 Reply Last reply
    0
    • S Sandeep Kalra

      Hi All Look at the code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DealingWithImages { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.label1 = new System.Windows.Forms.Label(); this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(53, 52); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(211, 13); this.label1.TabIndex = 2; this.label1.Text = "This is windows forms do you like it?"; this.Controls.Add(label1); Image myimage = Image.FromFile(@"Give path of the image"); this.BackgroundImage = myimage; this.MaximumSize = new System.Drawing.Size(400, 400); this.MinimumSize = new System.Drawing.Size(400, 400); } protected override void OnMove(EventArgs e) { base.OnMove(e); this.Refresh(); this.Invalidate(); } protected override void OnPaintBackground(PaintEventArgs e) { if (this.BackgroundImage != null) { e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; e.Graphics.DrawImage(this.BackgroundImage, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height); } else { base.OnPaintBackground(e); } } } } I have to put image on the background of my windows form which I am doing using the code above. I have some controls which I am generating at runtime. Now the challenge is the background color of the control(here label1) looks odd on the form. Does anybody know How to solve it? Thanks Regards THE SK

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      label1.BackColor = Color.Transparent;

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

      ----------------------------------------------- 128 bit encrypted signature, crack if you can

      S 1 Reply Last reply
      0
      • X Xmen Real

        label1.BackColor = Color.Transparent;

        TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

        ----------------------------------------------- 128 bit encrypted signature, crack if you can

        S Offline
        S Offline
        Sandeep Kalra
        wrote on last edited by
        #3

        thousands line question One line answer Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups