|
Although it is hard to guess without seeing your code, I think that the most probale reason is, that the control in question is private. So, to access the control from the second form, just set the control to public or provide public accessor in the first form.
|
|
|
|
|
That doesn't sound like a good way to do it. You likely want the second form to have an event and have the first form register a handler for that event.
|
|
|
|
|
See my article on events here[^] for a better method than constructor injection, in particular the section "Form Communication Using Events".
|
|
|
|
|
BasePriority = 'process.BasePriority' threw an exception of type 'System.InvalidOperationException'...This is the exception I am getting while restoring the database from my .net application..Here I am providing the code....
try
{
string path;
path = filetext.Text;
StreamReader file = new StreamReader(path);
string input = file.ReadToEnd();
file.Close();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqlimport.exe";
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = false;
psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}",
userid, paswd, server, comboBox1.Text);
psi.UseShellExecute = false;
Console.WriteLine(psi);
Process process = Process.Start(psi);
process.StandardInput.WriteLine(input);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
MessageBox.Show("database is restored");
}
catch (IOException ex)
{
MessageBox.Show("Error , unable to Restore!");
}
Plz provide any suggestion....
|
|
|
|
|
You cannot set the BasePriorty as this is a read only Property.
The return type of this property is an integer. Read more about this here[^] .
You have not provided the code for this statement, so its hard to figure out what you were trying to do.
|
|
|
|
|
|
As pointer reach to line Process process=process.start(psi), command line windows opens for a second and then closes and when after this line I watch the output it throws that exception that process has existed....
|
|
|
|
|
Yeah, I don't see such a statement, but maybe you need something like this:
try
{
process.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal ;
}
catch
{
/* The process probably already exited due to error */
}
|
|
|
|
|
yes sir process is already exiting due to error .........i am also unable to understand why the process is exiting ...give some solution thanks
|
|
|
|
|
You'll need to check the output. You may need to redirect and capture the output.
|
|
|
|
|
how i can do this ....provide what code i should use or steps to do that thanks in advance
|
|
|
|
|
You can print reports that personal information, now I hit the print icon in the report and display the print dialog box has two buttons ok and cancel, if you click ok it will print, but how do you know that have hit the ok button? Thank you very much.
|
|
|
|
|
Try:
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == DialogResult.OK)
{
....
}
BTW: Please do not post subjects in Vietnamese (or other languages) - most readers cannot understand it, so you reduce your chances of getting help. Google translate does a pretty good job:
Bắt sự kiện nút ok của hộp thoại print
Getting event print dialog's ok button
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hi , have a good day ,
I have Paired Nokia Mobile with my PC Windows 7 64 bit , through bluetooth
And Every thing works fine , Contacts , Messages , File Transfer ,
Even after I restart My PC or Turn my Mobile Bluetooh off/On , they connected Automatically ..
Except , one thing the "Telephony Audio Gateway!"
It does not Connect automatically , I have to press Connect Button from my PC Bluetooth settings , every time they connected again !
Setting Picture[^]
Thank you .
|
|
|
|
|
What does this have to do with C#?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Contact Nokia? Sounds like a user-problem, not programming-related.
Bastard Programmer from Hell
|
|
|
|
|
Nokia Restricted my country from accessing there web site
|
|
|
|
|
It is my understanding that the plug-in that would facilitate developing for the Blackberry has been retired. What tools, software,etc. are presently available to do so? Guidance sought
|
|
|
|
|
mauricemcse wrote: Guidance sought
Uhm... use this
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
im trying to upload,save the image and then want to move the image to another folder...
only when the control goes to move function i get this error (The process cannot access the file because it is being used by another process.)
//this is my 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;
using OnBarcode.Barcode.BarcodeScanner;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.IO;
namespace AutoImageProcessing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "*.jpg|*.jpg";
ofd.Multiselect = false;
ofd.Title = "Select JPEG File";
if (ofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = ofd.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
string path = textBox1.Text;
//->if (textBox1.Text != string.Empty)
if (path != string.Empty)
{
try
{
pictureBox1.Image = Image.FromFile(path);
//->String[] barcodes = BarcodeScanner.Scan(textBox1.Text, BarcodeType.All);
String[] barcodes = BarcodeScanner.Scan(path, BarcodeType.All);
// MessageBox.Show(barcodes[0]);
// Specify a "currently active folder"
//string activeDir = @"f:";
//Create a new subfolder under the current active folder
//string newPath1 = System.IO.Path.Combine(activeDir, "export");
string newPath = @"f:/export/" + barcodes[1];
//string newPath = System.IO.Path.Combine(activeDir1, barcodes[1]);
// Create the subfolder
System.IO.Directory.CreateDirectory(newPath);
// Create a new file name. This example generates
// a random string.
string newFileName = barcodes[1];
// Combine the new file name with the path
newPath = System.IO.Path.Combine(newPath, newFileName);
//cropping the signature and photograph
//saving the 2 cropped images into the folder
if (!System.IO.File.Exists(newPath))
{
try
{
Point start = new Point();
Point end = new Point();
int width;
int height;
using (Bitmap bitmap = new Bitmap(pictureBox1.Image))
{
bitmap.Save(newPath + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
}
MessageBox.Show("image saved!!!");
start.X = 305;
start.Y = 489;
end.X = 843;
end.Y = 569;
width = 538;
height = 80;
Rectangle imageRectangle = new Rectangle(start.X, start.Y, width, height);
if (start == new Point(0, 0) || end == new Point(0, 0))
{
MessageBox.Show("First select start and end point by clicking on the image");
}
else
{
try
{
pictureBox1.Image = cropImage(pictureBox1.Image, imageRectangle);
using (Bitmap bitmap = new Bitmap(pictureBox1.Image))
{
bitmap.Save(newPath + "_barcode.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
}
MessageBox.Show("image saved!!!");
}
catch (Exception ex)
{
MessageBox.Show("this is the error \n" + ex.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show("An Error has occured: \n" + ex.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show("An Error has occured: \n" + ex.Message);
return;
}
}
else
{
MessageBox.Show("Please Enter Location of Image");
}
try
{
Image.FromFile(path).Dispose();
MessageBox.Show("entering move function");
Process end=Process.GetCurrentProcess();
MessageBox.Show(end.ToString());
end.Dispose();
end.Close();
}
catch(IOException w)
{
MessageBox.Show("error"+w.Message);
}
try
{
System.IO.File.Move(path, @"f:\img_pr");
MessageBox.Show("move completed");
}
catch (IOException w)
{
MessageBox.Show("error" + w.Message);
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private Image cropImage(Image image, Rectangle imageRectangle)
{
Bitmap bitmap1 = new Bitmap(image);
Bitmap cropedBitmap = bitmap1.Clone(imageRectangle, bitmap1.PixelFormat);
return (Image)(cropedBitmap);
}
private Image bitmap2(Image image, Rectangle rectangle)
{
throw new NotImplementedException();
}
}
}
|
|
|
|
|
If you are going to post that much code, then please make sure you have formatted it - edit your message, and surround the code with
<pre lang="cs"> At the top, and
</pre> at the bottom.
This will preserve the indentation, and make it much, much easier to read!
Example: As you have it:
private void ClickButton(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("ClickButton: Needs a button name");
}
else
{
FieldInfo fi = this.GetType().GetField(name);
if (fi == null)
{
throw new ArgumentException(string.Format("ClickButton: Button \"{0}\" not found", name));
}
else
{
Button bnew = fi.GetValue(this) as Button;
if (bnew == null)
{
throw new ArgumentException(string.Format("ClickButton: \"{0}\" is not a button", name));
}
else
{
bnew.PerformClick();
}
}
}
}
With tags round it:
private void ClickButton(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("ClickButton: Needs a button name");
}
else
{
FieldInfo fi = this.GetType().GetField(name);
if (fi == null)
{
throw new ArgumentException(string.Format("ClickButton: Button \"{0}\" not found", name));
}
else
{
Button bnew = fi.GetValue(this) as Button;
if (bnew == null)
{
throw new ArgumentException(string.Format("ClickButton: \"{0}\" is not a button", name));
}
else
{
bnew.PerformClick();
}
}
}
}
I for one, am not looking at it as it is!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
That is unreadable; please use <PRE> tags to preserve formatting and get an appropriate font.
I am guessing one of three things happened:
1. you forgot to close the file.
2. something you did causes the file to be locked (is there a PictureBox? or an Image.FromFile?)
3. if the file is newly created, it may be currently being read by another program (an indexer, an antivirus, whatever), so you may have to retry later.
|
|
|
|
|
The problem you have is caused by Image.FromFile http://support.microsoft.com/kb/309482[^] which is locking the file and preventing reuse in the same process. The reference to another process in the error message is very misleading.
The work arounds are
1) Create a new Bitmap from the Image and then dispose of the Image
2) Create the Image by using the FromStream method and then dispose of the FileStream
Example code for these are
private const String ImageFile = @"E:\VC\Projects\CP\InUseImages\Pic.jpg";
private void LoadLockedImage() {
using (Image temp = Image.FromFile(ImageFile)) {
pictureBox1.Image = temp;
using (FileStream fs = new FileStream(ImageFile, FileMode.Open)) {
}
}
}
private void LoadFreeImage() {
using (Image temp = Image.FromFile(ImageFile)) {
pictureBox1.Image = new Bitmap(temp);
}
using (FileStream fs = new FileStream(ImageFile, FileMode.Open)) {
}
}
private void LoadFreeImage2() {
using (FileStream fs = new FileStream(ImageFile, FileMode.Open)) {
pictureBox1.Image = Image.FromStream(fs);
}
using (FileStream fs = new FileStream(ImageFile, FileMode.Open)) {
}
}
Alan.
|
|
|
|
|
thanx alot alan..
|
|
|
|
|
whitch are better to start and learn .
send me at sfa88electronic@gmail.com
|
|
|
|