473,395 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Background images of form and groupboxes?

Just wondering how to change the background image of a group box or the form
through code = /.

Thanks
Apr 6 '07 #1
2 1130
Try this code. Drag a button onto your form and name it bgImage. Double click on it to generate an event handler and insert the following code.
Hope it helps!
Richard

private void bgImage_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap
(this.ClientRectangle.Width,this.ClientRectangle.H eight);
Graphics g = Graphics.FromImage(myBitmap);
g.FillRectangle(Brushes.White, this.ClientRectangle);
// 2 is the rectangle width
for (int intX = 1; (intX+2) < this.Width; intX+=10)
{
for (int intY = 1; (intY+2) < this.Height; intY += 10 )
{
//fill a rectangle that is 2 pixels wide
g.FillRectangle(Brushes.Red, intX,intY,2,2);
}
}
g.DrawString("My Custom Background", new Font(this.Font.FontFamily, 14, FontStyle.Bold), Brushes.LightGray, 30, 30);

//dispose the graphics object.
g.Dispose();
//set the bg image to the custom bitmap. Note: you can add any image to the forms background.
this.BackgroundImage = myBitmap;
this.Invalidate();
}
Apr 8 '07 #2
thanks very much!!
Apr 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Markus Mohr | last post by:
Hi, everyone, I have a special problem: For every monitor resolution in 200 pixel steps from 800 to 1600 pixels I have an image to be shown as centered background-image. Those images all...
5
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I...
6
by: John Ortt | last post by:
Hi there everyone, I have a part info form which has a faded image of our company logo as a background. I want to replace the faded image with a bright red warning image on items which have run...
0
by: ghadley_00 | last post by:
MS Access Create form / report with multiple pages using different background images Hi, Would like to have users fill out a multipage form, and then click a print button, which pulls up the...
6
by: Frank | last post by:
I have several groupboxes in a form, and I need to go through them to check some things. Thus I have a Sub like this: Dim grpbox_temp As GroupBox Dim cbox_temp As CheckBox For Each...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
5
denny1824
by: denny1824 | last post by:
I want each cell in a table on the Master page to have its own background image. The images exist, but none of them show on the page. <body> <form id="form1" runat="server"> <table...
0
by: ton | last post by:
Hi, I have an Image which is dark grey/black, at the top a white line, at the left site a white line as well. At 192 px from the left of the screen I position a DIV with this image as the...
2
by: thephatp | last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE. I have created a sample page, and I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.