Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: redraw problem GDI+ Pin
Christian Graus14-Mar-07 9:24
protectorChristian Graus14-Mar-07 9:24 
GeneralRe: redraw problem GDI+ Pin
Dave Kreskowiak14-Mar-07 9:28
mveDave Kreskowiak14-Mar-07 9:28 
GeneralRe: redraw problem GDI+ Pin
Christian Graus14-Mar-07 9:32
protectorChristian Graus14-Mar-07 9:32 
GeneralRe: redraw problem GDI+ Pin
Dave Kreskowiak14-Mar-07 11:51
mveDave Kreskowiak14-Mar-07 11:51 
AnswerRe: redraw problem GDI+ Pin
Christian Graus14-Mar-07 9:23
protectorChristian Graus14-Mar-07 9:23 
GeneralRe: redraw problem GDI+ Pin
_tasleem15-Mar-07 2:41
_tasleem15-Mar-07 2:41 
QuestionCrystall Report on C# 2005 Express Editiion. [modified] Pin
msogun14-Mar-07 7:22
msogun14-Mar-07 7:22 
QuestionLoading in a background on my form problem Pin
lee.hallows14-Mar-07 7:03
lee.hallows14-Mar-07 7:03 
Appologise for my earlier post, as mention before i am a new programmer and my posting etiquette needs improving.... again i appologies.

Can anyone help me with a problem of loading in a backgroun onto my form. I know you can load a picture box from the tool box and set this as your background but this is not what i'm try to achieve.

The problem appears to be in this line of my code (code added at bottom)

Bitmap background = new Bitmap(GetType(), "background.jpg");

I get the following error when press F5 to run my app.....

Resource 'background.jpg' cannot be found in class 'Game.Form1'

I have added this image as a resource (solution explorer > title properties > resources > add image.

This is my code in full:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data;

namespace Game
{
public partial class Form1 : Form
{
// insert private bitmap background
// and movement int x/y move etc.....

private Bitmap background = new Bitmap(640, 320);
//private Bitmap car;
//private Bitmap player;


public Form1()
{
InitializeComponent();

//player = new Bitmap(GetType(), "player.jpg");
//car = new Bitmap(GetType(), "car.jpg");
Bitmap background = new Bitmap(GetType(), "background.jpg");

this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);

Graphics g = Graphics.FromImage(background);

for (int x = 0; x < 640; x += 90)
for (int y = 0; y <= 290; y += 90)
{
g.DrawImage(background, new Rectangle(x, y, 90, 90)); // GraphicsUnit.Pixel);
}
}

}
}

Regards,

Thank you for taking the time to read this Smile | :)
AnswerRe: Loading in a background on my form problem Pin
Judah Gabriel Himango14-Mar-07 7:41
sponsorJudah Gabriel Himango14-Mar-07 7:41 
QuestionStrange problem with WebBrowser control &quot;double loading&quot; a page, eh? Pin
ThisIsMyUserName214-Mar-07 6:57
ThisIsMyUserName214-Mar-07 6:57 
AnswerRe: Strange problem with WebBrowser control "double loading" a page, eh? Pin
led mike14-Mar-07 7:19
led mike14-Mar-07 7:19 
GeneralRe: Strange problem with WebBrowser control "double loading" a page, eh? [modified] Pin
ThisIsMyUserName214-Mar-07 7:41
ThisIsMyUserName214-Mar-07 7:41 
GeneralRe: Strange problem with WebBrowser control "double loading" a page, eh? Pin
led mike14-Mar-07 8:15
led mike14-Mar-07 8:15 
GeneralRe: Strange problem with WebBrowser control "double loading" a page, eh? Pin
ThisIsMyUserName214-Mar-07 8:33
ThisIsMyUserName214-Mar-07 8:33 
GeneralRe: Strange problem with WebBrowser control "double loading" a page, eh? Pin
Dave Kreskowiak14-Mar-07 9:20
mveDave Kreskowiak14-Mar-07 9:20 
GeneralRe: Strange problem with WebBrowser control "double loading" a page, eh? Pin
ThisIsMyUserName214-Mar-07 9:50
ThisIsMyUserName214-Mar-07 9:50 
QuestionHow to call different namespace Pin
Eyungwah14-Mar-07 6:57
Eyungwah14-Mar-07 6:57 
AnswerRe: How to call different namespace Pin
led mike14-Mar-07 7:12
led mike14-Mar-07 7:12 
AnswerRe: How to call different namespace Pin
Colin Angus Mackay14-Mar-07 9:03
Colin Angus Mackay14-Mar-07 9:03 
Questionxml question Pin
groundzero11114-Mar-07 6:43
groundzero11114-Mar-07 6:43 
AnswerRe: xml question Pin
ThisIsMyUserName214-Mar-07 7:23
ThisIsMyUserName214-Mar-07 7:23 
GeneralRe: xml question Pin
groundzero11114-Mar-07 8:48
groundzero11114-Mar-07 8:48 
GeneralRe: xml question Pin
Stefan Troschuetz14-Mar-07 12:10
Stefan Troschuetz14-Mar-07 12:10 
Questionpaging in DataGrid using C# and windows forms Pin
OmarLodhi14-Mar-07 5:54
OmarLodhi14-Mar-07 5:54 
QuestionCreating a tiny SQL Windows XP "Registry Cleaner" Application Pin
td0014-Mar-07 5:48
td0014-Mar-07 5:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.