|
oke, but i need to put a lot of information on the form, do i need to create a delegate for every textbox?
|
|
|
|
|
No just a parameter for every control, or a list, or a very long string with separators(not the best way), or a datatable, or...
Basicly your delegate will call a function and in that function you then have those parameters and can assign them to the right control (aka fill in the textbox)
|
|
|
|
|
Joramq wrote: do i need to create a delegate for every textbox?
No. Create a class which contains all required fields and pass the class instance through parameter.
|
|
|
|
|
Hi,
this won't work. Even when you fix the problems and get the optionbox returned, you can't touch it from another thread, so you still need a lot of InvokeRequired/Invoke stuff to feed it all the data.
Here is a better approach: put all the data you want to show or update on the form into one object (create a Results class), and teach your form to show a Results object. Then use the InvokeRequired/Invoke pattern to pass one Results object to your Form, and have it update itself accordingly.
BTW: if your option box is showing some initial settings that are persisted in a text file (maybe XML), pass the file path to the Form, and learn it how to adapt to the content of the file; and provide another method to dump its state to that file; etc.
|
|
|
|
|
hmm, yeah haven't thought about that. i think i can create that. Thanks!
|
|
|
|
|
hello frds..........
i m creating a collg project job searching website...
In user table email address of user are stored.
if i want admin of my application to provie afunctionality to send email about job alerts to all users how cn i do it?
is it possible?
at which time i should send an email of registrain confiration?at registration time or it does the admin manually?
If database is so large is it possible to send email to all members using there addresses from data base directaly?
pls help...
tell about any idea related to this...
|
|
|
|
|
There is no problem in sending mails to multiple users. Just retrieve the email id's from database by inserting a comma after each email id AND place the resultant string to 'To' property of MailMessage object.
Happy Coding....
|
|
|
|
|
I have the following two functions:
private void freezeFrame_MouseClick(object sender, MouseEventArgs e)
{
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
getPixel();
}
private void getPixel()
{
int rangeLimit = 20;
int mouseX = int.Parse(txtMouseX.Text);
int mouseY = int.Parse(txtMouseY.Text);
Bitmap refBitmap = null;
System.Drawing.Image refImage = null;
refImage = freezeFrame.Image;
refBitmap = new Bitmap(refImage);
Color currentPixel = (refBitmap.GetPixel(mouseX, mouseY));
curPixelRed.Text = currentPixel.R.ToString();
curPixelGreen.Text = currentPixel.G.ToString();
curPixelBlue.Text = currentPixel.B.ToString();
redMinUpDown.Value = currentPixel.R - rangeLimit;
redMaxUpDown.Value = currentPixel.R + rangeLimit;
greenMinUpDown.Value = currentPixel.G - rangeLimit;
greenMaxUpDown.Value = currentPixel.G + rangeLimit;
blueMinUpDown.Value = currentPixel.B - rangeLimit;
blueMaxUpDown.Value = currentPixel.B + rangeLimit;
}
when i run the code, and click on the picturebox i get the following error "ArgumentException was unhandeled" with the statement "Parameter is not valid" for the line refBitmap = new Bitmap(refImage). I tried changing up the way i declare the refImage and refBitmap as suggested by people on my previous question and nothing works. What should I do?
When I debug, the Locals are as follows:
rangeLimit = 20
mouseX = 70 (red)
mouseY = 91 (red)
reBitmap = null
refImage = {System.Drawing.Bitmap}
currentPixel = "{Name=0, ARGB=(0,0,0,0)}"
Is there a direct way to convert a System.Drawing.Image to System.Drawing.Bitmap? I tried what someone else instructed me to do and I keep getting the same error and if I ask this question again, people just bash me on the fact that the code is low quality or other non-constructive criticism. All i need is to figure out what is wrong with my code, not a lecture on why i suck as a programmer. We all start somewhere and we all make mistakes but I digress. Can anyone help me solve this dilemma?
|
|
|
|
|
Bitmap bitmap = (Bitmap)image;
|
|
|
|
|
This obviously won't work.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
This is terrible code. Very inefficient. Is GetPixel a method in the Bitmap class and not Image ? This will make your code even less efficient, but the way to do it is
Bitmap b = new Bitmap(myImage);
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I have just created a test project and pasted your code into it. It works perfectly.
So, question. What event are you handling with freezeFrame_MouseClick ? You see I tried it with both MouseClick and MouseDown of the PictureBox , and it worked for both.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi dudes!
Does anyone know how can I change the version of my config files?
Why does it just accept 1.0?
|
|
|
|
|
Assembly Version: 1.0.*
and Clear all the File version.
*12Code
|
|
|
|
|
Thanx! So the config file version cannot be more detailed!
|
|
|
|
|
I get this error, even though I don't know why.
The code throwing this error is this:
bool ReadIni()
{
try
{
string error = "";
try
{
}
catch (Exception ex)
{
}
if (ini != null)
{
}
else
{
for (int i = 0; i < 5; i++)
{
conversion[i] = false;
}
}
if (error != "" || ini == null)
{
MessageBox.Show(error + "\r\nPlease input the missing values", "Input missing
values", MessageBoxButtons.OK, MessageBoxIcon.Error);
F_Manual_Input forminput = new F_Manual_Input(conversion, values, inipath);
this.Show();
forminput.ShowDialog();
this.mapsize = new Size(forminput.MapWidth, forminput.MapHeight);
this.tilewidth = forminput.TileWidth;
this.tileheight = forminput.TileHeight;
return false;
}
else
{
this.mapsize = new Size(sizeX, sizeY);
this.tilewidth = tileX;
this.tileheight = tileY;
this.imagewidth = sourceX;
return true;
}
}
catch (Exception ex)
{
MessageBox.Show("An error occurred while reading the ini file:\r\n" + ex.Message,
"System Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} The final if/else block causes the error.
Even if I out comment it and write return true; instead, I get the same error.
But I don't know why I get it in the first place.
All the code before the final if/else block will just be executed one after another normally and there are no unresolved if blocks or anything, no way the method could stop there.
And the final if/else block catching 2 different cases, but also returns avalue in all other cases.
I'd really appreciate if you could tell me what went wrong.
|
|
|
|
|
Megidolaon wrote: else
{
//set map/tile size and image width with values from file
this.mapsize = new Size(sizeX, sizeY);
this.tilewidth = tileX;
this.tileheight = tileY;
this.imagewidth = sourceX;
return true; //input was read from file
}
add another
return false;
after the code.
*12Code
|
|
|
|
|
I still get the same error.
In fact VS tells me it's unreachable code.
|
|
|
|
|
Just put return statment after the catch blok,
catch (Exception ex) { MessageBox.Show("An error occurred while reading the ini file:\r\n" + ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
return false;
|
|
|
|
|
The method is supposed to continue if there's an error with read the ini file in the first place (like missing file, etc.).
The user must enter the values manually and the application will create the ini from scratch.
|
|
|
|
|
Declare a local bool variable first and then set the variable to either true or false in the IF ELSE blocks. In the end return the variable
The code should look like the following...
bool ReadIni()
{
bool returnValue = false;
try
{
}
catch (Exception ex)
{
}
return returnValue
}
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Yeah, it never happened to me, but I realized that in case of an exception, that exception is caught and afterwards the application continues normally.
Thus in this case it also need a return value.
|
|
|
|
|
I have a project in C#. Now i have this problem: after installing this software it should be disabled and the user must register it in our website, then with an activation key that would be given in the website the software should be enabled again!
I really know nothing about how it should be done.
Would anybody please help me???
it's so urgent!!!
Roshanak
|
|
|
|
|
Urgent for who?
Simple: have the startup check for a value in the registry that is an anagram "satryuopoied". If it's not there phone home.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
yes, i found it.
now i have my own software, you mean if i install it (for example with windows installer) it creates this registry key for it's own and then i can do what i want??? or i must insert the creation of this key in my code????
Roshanak
|
|
|
|