|
Hi, I would solve the problem with handling of MouseEnter and MouseLeave events.
Example:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace MouseOverPictureBox
{
static class Program
{
static void Main()
{
Form form = new Form();
PictureBox pb = new PictureBox();
pb.BackColor = Color.Red;
pb.MouseEnter += delegate(object sender, EventArgs e)
{
form.BackColor = Color.Green;
};
pb.MouseLeave += delegate(object sender, EventArgs e)
{
form.BackColor = SystemColors.Control;
};
form.Controls.Add(pb);
Application.Run(form);
}
}
}
|
|
|
|
|
I have an XMLDocuemt supplied by a 3rd party. I have an xpath expression checking for value for element "x". The problem is sometimes element "x" does not exist and im getting a error "bject reference not set to an instance of an Object".
How do i check if element x (using xpath) exist
|
|
|
|
|
Check for null the result of the XPath query before using the Value property.
|
|
|
|
|
Hi, I have an asp.net web application, I have read/write a word file with the help of openxml sdk. Now I need to convert that word file to a pdf format. Is there anyway to convert word file to pdf with the openxml sdk ? Pankaj
|
|
|
|
|
Ok Guys I'm facing a strange problem here, and I dunno if its a bug or I am doing something wrong.
Here's the code:
using System;
using System.Diagnostics;
using System.Net;
using System.Windows.Forms;
namespace ConsoleApplication
{
internal class Program
{
private static void Main(string[] args)
{
var webClient = new WebClient();
webClient.DownloadProgressChanged += (o, e) => Debug.WriteLine(e.ProgressPercentage);
webClient.DownloadFileCompleted += (o, e) => Debug.WriteLine("Download completed.");
Debug.WriteLine("Starting download...");
webClient.DownloadFileAsync(new Uri("http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-netinst.iso"), "debian-504-i386-netinst.iso");
Console.Read();
}
}
}
Everything works fine like this, events are raised normally.
Now try to uncomment the progressbar initialization and events will stop to be fired (I noticed the problem with the progress bar because I needed to add a progress bar dynamically to the form, dunno if there are other scenarios where this happens) even if the download proceeds normally.
Maybe is just me or maybe I have convinced myself this code is right that I cant no longer see where I epic fail.
Anyone having the same problem?
Thanks in advance.
Matt
|
|
|
|
|
Hi, this looks strange! I'd guess your problem in the example is Console.Read()... When I tried your code in an windows forms project there was no problem. Can you show your orignal code
Teuz wrote: (I noticed the problem with the progress bar because I needed to add a progress bar dynamically to the form, dunno if there are other scenarios where this happens)
|
|
|
|
|
Thank you for the reply.
How did you managed to make it work in a windows form project? This code acts exactly like the console one, no event are fired but the file is downloaded:
using System;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void CheckUpdate(object arg)
{
DownloadFile();
Thread.Sleep(5000);
Debug.WriteLine("Update completed");
}
public void DownloadFile()
{
var webClient = new WebClient();
var progressBar = new ProgressBar();
AddControl(progressBar);
webClient.DownloadProgressChanged += (o, e) =>
{
Debug.WriteLine(e.ProgressPercentage);
progressBar.Value = e.ProgressPercentage;
};
webClient.DownloadFileCompleted += (o, e) => Debug.WriteLine("Download completed.");
Debug.WriteLine("Starting download...");
webClient.DownloadFileAsync(new Uri("http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-netinst.iso"), "debian-504-i386-netinst.iso");
}
private void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(CheckUpdate);
}
private void AddControl(Control control)
{
if (flowLayoutPanel1.InvokeRequired)
flowLayoutPanel1.BeginInvoke(new MethodInvoker(() => AddControl(control)));
else
flowLayoutPanel1.Controls.Add(control);
}
}
}
This is also quite similar the code I'm actually using in my project. I forgot to mention that for this project I'm using NET 2.0 so maybe this can work differently in later versions.
|
|
|
|
|
please tell me Error in My Coding
My Coding Is
OdbcConnection conn = new OdbcConnection("Driver={Microsoft Access Driver (*.mdb)};Dbq=D:\\Opal Agro Chemical\\OpalAgroChemical.mdb;Uid=;Pwd=;");
string Invqurey = "insert into invoice(id,date,gpno,product,customer,qty,carton,rate,amount,bilty,expdate) values('" + inid.Text + "','" + dt.Text + "','" + gpno.Text + "','" + prod.Text + "','" + cust.Text + "','" + qty.Text + "','" + carton.Text + "','" + rate.Text + "','" + amount.Text + "','" + bilty.Text + "','" + expdate.Text +"')";
OdbcCommand cmd = new OdbcCommand(Invqurey, conn);
conn.Open();
MessageBox.Show(cmd.CommandText);
cmd.ExecuteNonQuery();
conn.Close();
This Error Is Showing When i Insert Record
System.Data.Odbc.OdbcException was unhandled
Message="ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement."
Source="odbcjt32.dll"
ErrorCode=-2146232009
Please Help Me
Thanks In Advance
Jawad Khatri
|
|
|
|
|
Get rid of the problem, and potential SQL injection attacks by using Parameterized queries:
string Invqurey = "INSERT INTO invoice (id, date, gpno, product, customer, qty, carton, rate, amount, bilty, expdate)" +
" VALUES (@inid, @dt, @gpno, @prod, @cust, @qty, @carton, @rate, @amount, @bilty, @expdate)";
OdbcCommand cmd = new OdbcCommand(Invqurey, conn);
cmd.AddWithValue("@inid", inid.Text);
cmd.AddWithValue("@gpno", gpno.Text);
... Oh - and the standard is to use UPPERCASE for SQL keywords.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: Oh - and the standard is to use UPPERCASE for SQL keywords.
In every code shop and software house I've been in for over 20 years the standard has always been lower case! Don't want to start an argument, just saying that the real standard is that there are no real standards...Tychotics: take us back to the moon
"Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars."
H. G. Wells
|
|
|
|
|
get the content onv Invqurey, an ask then the question in the SQL forum.
|
|
|
|
|
Hi
I am trying to write a TypeConverter for SubProperties, in this case the BooleanConverter.
I managed to use the BooleanConverter with Bool-Fields that are MainProperties, but not with BoolProperties that are SubProperties.
I am using the Font-Property for my Controls, but I'd like to translate all the values in a different language.
But how is it possible to use the BooleanConverter (or something like it) for the Bool-Values inside the Font-Property (so for example for the SubProperty "Bold").
So I'd like to change the "Yes" and "No" in the DropDown Box for "Bold".
I hope you know what I mean/try to explain
Thanks in advance for your help
|
|
|
|
|
Hi to all,
I am working on academic project. I require some help, please help me any one who knows the answer for following:
In my college 20 systems are connected with home network. Where we have a share(every system can access this space) drive. Now I developed a professor details interface.
This professor details is placed at shared location. So that any student can access this information from any system.
How can write such kind of application(using windows based C# application).
Please if you have any links related this share me.
Thanks In advance..To invent something, you need a mountain of junk in your mind.
---------------------Thomas alva edison
|
|
|
|
|
It's Easy.
If your application is using Database. You can use SQL Server or Oracle.If you can think then I Can.
|
|
|
|
|
Thanks for quick reply,
Data base point of view ok. I will use SQLServer.
i want to know,how to access access user interface. How to create shortcut on each desktop. So that my application should located in shared drive and access to every one.To invent something, you need a mountain of junk in your mind.
---------------------Thomas alva edison
|
|
|
|
|
You have a lot of question.
You can use MSaccess database but it's not friendly for MULTIUSER infrastructure. and you can connect server and other machines by using connection string.If you can think then I Can.
|
|
|
|
|
sampath-padamatinti wrote: How to create shortcut on each desktop.
Exactly the same way that you create any shortcut; the link will point to the app on the share rather than on the local disk.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
i want to validate first if the form is already loaded or not.
if it is already loaded the form will just prompt it again perform it windows state to normal and focus but does not duplicate the form..
<br />
<br />
<br />
private void newToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
<br />
<br />
if (IsFormLoaded("form2"))<br />
{<br />
return;<br />
}<br />
<br />
<br />
Form1 frmshow = new Form1(); <br />
frmshow.MdiParent = this;<br />
frmshow.Show();<br />
<br />
}<br />
<br />
private bool IsFormLoaded(string formName)<br />
{<br />
bool Load = false;<br />
<br />
for (int i = 0; i < (this.OwnedForms.Length) - 1; i++)<br />
{<br />
<br />
if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName")<br />
{<br />
this.OwnedForms[i].WindowState = FormWindowState.Normal;<br />
this.OwnedForms[i].Focus();<br />
Load = true;<br />
}<br />
<br />
}<br />
<br />
return Load;<br />
}<br />
<br />
<br />
<br />
|
|
|
|
|
why are you using hardcoded form name
if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName")
"formName" should be formNameLife's Like a mirror. Smile at it & it smiles back at you.- P Pligrim
So Smile Please
|
|
|
|
|
Please, don't repost a question so quickly. Your original question is only a couple of questions down, so be patient and post any updates to your question on that one. Don't start a new thread as this is rude."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
I had a setup (of plugin of IE) (named Setup1) build in vs2005. Earlier If I used to install this setup on other PC's which doesn't have vs2005 and has only .Net framework2.0, the setup gets successfully installed.
After few days, I had installed vs2008 in my PC. After that, I had took the code of Setup1, rebuilt the dll, made a setup (named Setup2) using vs2005.
The main thing is, I had observed one thing, the new setup (i.e., Setup2) gets successfully installed on developing machines, but it gives the following installation error on the machines which does not have vistualstudio, eventhough, .Netframework2.0 and windowsinstaller3.1 is present. The error is:
Exception occured while initializing the installation:
System.IO.FileLoadException: could not load file or assembly 'Microsoft.mshtml.dll, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. StrongName validation failed. (Exception from HRESULT:0x8013141A).
But on the same, Setup1 gets succesfully installed. But setup2 gives this installation Error.
If I run vs_piaredist.exe first and then run the Setup2, Setup2 also gets successfully installed.
Why is this happening with Setup2? why doesn't this happen with Setup1?
|
|
|
|
|
In my case it was because I referenced different "Microsoft.mshtml.dll" files (same file size, but different content). look at the Reference "Microsoft.mshtml.dll" , "Properties", "Path" field.
more details in myanswer to http://stackoverflow.com/questions/2068159/[^]Atara
|
|
|
|
|
Dear All:
I am a bit confused about the delegate with a returned value.
For example, I have a delegate as:
public delegate int Adelegate(MyClass instance)
Like this, what happens to the returned value if I use multi delegate please?
Further, if the delegate returns a bool, how can I declare a delegate that output a bool value please?
Should I declare it in the parameters or the return value?
ThanksAsura
|
|
|
|
|
|
<br />
private void newToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
<br />
if (IsFormLoaded("form1"))<br />
return;<br />
<br />
else<br />
{<br />
<br />
Form1 frmshow = new Form1();<br />
frmshow.MdiParent = this;<br />
frmshow.Show();<br />
}<br />
<br />
<br />
}<br />
<br />
private bool IsFormLoaded(string formName)<br />
{<br />
bool FormLoaded = false;<br />
<br />
for (int i = 0; i < (this.OwnedForms.Length) - 1; i++)<br />
{<br />
<br />
if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName")<br />
{<br />
this.OwnedForms[i].WindowState = FormWindowState.Normal;<br />
this.OwnedForms[i].Focus();<br />
FormLoaded = true;<br />
}<br />
<br />
}<br />
<br />
return FormLoaded;<br />
}<br />
<br />
<br />
<br />
<br />
not functioning<div class="signature"><div class="modified">modified on Sunday, March 7, 2010 9:52 PM</div></div>
|
|
|
|
|