|
hi,
i'm using VS.NET 2003 and I would like to add some systemtray functionality to my C# application. The SystemTray icon should support the follwoing features:
1. Display Baloon Tooltips
2. Display a context menu when right clicked
3. Repsond to mouse events such as Click, DoubleClick etc.
...and other such suff
ANyone know a good class that would help me do this. I have a came across a few but each of them lack some or the other feature. I'm looking for a free one - don't wanna shell out a penny for this one. :->
|
|
|
|
|
NotifyIcon[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
cool, but i guess it doesnt support balloon tooltips.
|
|
|
|
|
From MSDN: "The Text property assigns ToolTip text."
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Greetings!
I was wondering if I could get some direction to get me started in implementing a "copy/paste" of the properties of a UserControl.
In my application, I have 10 instances of a particular UserControl. This UserControl has, say, 10 properties. I would like to be able to use the right-click menu that I have for this UserControl and be able to copy the "settings" of one instance to any other instance of the UserControl.
From what I've read on MSDN, I understand that I have to make the UserControl class Serializable and that the variables that I do not copied can be excluded using the [NonSerializable] attribute, thus so:
<br />
[Serializable]<br />
<br />
public class ctlMyControl : ctlBaseControl<br />
{<br />
int nNum1;
float fNum2;
<br />
[NonSerializable]<br />
float fNum3;
<br />
}
My question is how does one implement the actualy copy and paste?
What function(s) do I use to perform the copy and what function(s) do I use to paste?
Your help is appreciated!
Thanks!
-- modified at 13:39 Thursday 6th July, 2006
|
|
|
|
|
Well, I'm not sure about the right-click menu, but serializing is a trick you can use to copy a complex object. Mark the class as Serializable and then use the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter . You binary serialize your object into a MemoryStream and then deserialize it into a new object. Voila - a copy of your original without having to hand-code all the copying.
Logifusion[^]
|
|
|
|
|
Hi Dustin,
Could you give me some example code or point me to some examples of how this could be done?
Thanks for your time!
|
|
|
|
|
Sure thing. I needed to be able to copy a CodeCompileUnit object. This represents an entire CodeDom graph which can get really huge. It's a Microsoft library, so I can't just edit the code myself, and digging through the entire graph to copy it would not only be tedious but potentially faulty. It's just not an option. Luckily, serialization is there:
private CodeCompileUnit CopyCcu(CodeCompileUnit ccu) {
try {
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, ccu);
ms.Position = 0L;
CodeCompileUnit newCcu = bf.Deserialize(ms) as CodeCompileUnit;
return newCcu;
}
catch (Exception exc) {
}
}
This is at least how you would get a copy of your UserControl . I'm lost on the whole right-click thing. Where are you doing that? In the Visual Studio designer?
Logifusion[^]
|
|
|
|
|
This is not exactly a C# question, but I'm not sure where else to ask it.
I have an Access database program I wrote some years earlier. I am porting it into C# and trying to import the data from the older database to a newer version of the same database. Some tables are not identical, so I am writing an import feature.
The problem I am having is when importing from a memo or text field where the data includes " or ' characters since these characters are needed outside the SQL statement to indicate a text import.
Example: "INSERT INTO [Table] ([Field1]) VALUES ('This is a 'very' large project.')
Thanks in advance for any help.
S Hurt
|
|
|
|
|
Stephen Hurt wrote: but I'm not sure where else to ask it.
Stephen Hurt wrote: "INSERT INTO [Table] ([Field1]) VALUES ('This is a 'very' large project.')
Well since that is a SQL statement I would think the SQL / ADO / ADO.NET forum might be helpful?
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I think you just double up the single quotes:
Example: "INSERT INTO [Table] ([Field1]) VALUES ('This is a ''very'' large project.')
|
|
|
|
|
I have a command button that I basically want it to do one thing the first time, and something else on subsequent clicks.
I have a datagrid and the user clicks a button to add a line. The first time this happens, I need to go thru the BindData method to get everything initialized.
For subsequent clicks, I just want it to add the lines. I don't want to have to go through a postback, because I either end up with the first added line reset or I get the object reference not set to an instance error.
private void Button2_Click(object sender, System.EventArgs e)<br />
{ <br />
<br />
DataGridItemCollection items = dgParts.Items;<br />
int rows = items.Count;<br />
if (rows == 0)<br />
{<br />
BindData();<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}<br />
<br />
else<br />
{<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
}
When I click the button the second time my row count does say it has one row and tries to run through the else statement, but I get the null error thing.
I've been stuck on this for several days so if someone has any idea of a solution you will be my hero!
|
|
|
|
|
That is because you haven't assigned any value to the dt variable.
---
b { font-weight: normal; }
|
|
|
|
|
I have a new goofy error. When I hit button 2 (the if/else button I'm referring to) the code does not hit it. When I change the code back to what I had (which was not an if/else) it hits the code
Old code:
private void Button2_Click(object sender, System.EventArgs e)<br />
{ <br />
BindData();<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();
New code that it doesn't call:
DataGridItemCollection items = dgParts.Items;<br />
<br />
int rows = items.Count;<br />
if (rows == 0)<br />
{<br />
BindData();<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}<br />
<br />
else<br />
{<br />
DataTable dt = ds.Tables["Rest"];<br />
ds = (DataSet) Session["ds"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}
Previously I got the program to at least call the if/else when I was messing around with the code.
I do not have BindData in my Page_Load function because I want to call it when I actually need it. Does this have something to do with it?
|
|
|
|
|
Is it just the else block that isn't getting hit? Would it hurt to put the BindData call inside the else block?
|
|
|
|
|
The entire button2_click is not getting called. I went line by line in the debugger. In the one I wrote out, it goes through as expected. But the one with the if/else, it doesn't even look at it. Okay, must have had something commented because now it at least runs through the if/else. Still getting the null error.
This is what I now have:
private void Button2_Click(object sender, System.EventArgs e)<br />
{ <br />
<br />
DataGridItemCollection items = dgParts.Items;<br />
<br />
int rows = items.Count;<br />
if (rows == 0)<br />
{<br />
BindData();<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}<br />
<br />
else<br />
{<br />
DataTable dt = ds.Tables["Rest"]; ds = (DataSet) Session["ds"];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}
It bombs out at the line bolded.
-- modified at 14:00 Thursday 6th July, 2006
|
|
|
|
|
leckey wrote: must have had something commented
Oops, that happens
|
|
|
|
|
leckey wrote: Still getting the null error.
Is it because of ds? I do not see it being declared or initialized anywheres. You may want to hand optimize the if block and else block by pulling all of the common code out in front of the if statement, if at all possible
|
|
|
|
|
Look at this code:
DataTable dt = ds.Tables["Rest"]; ds = (DataSet) Session["ds"];
You are using ds before you assign a value to it.
---
b { font-weight: normal; }
|
|
|
|
|
D'oh! Okay, I get it to add a second line. (Small steps...small steps.)
New problem (imagine that!) When it adds the second line, it resets the first line. So anything I had previously entered is blanked out. How do I get it to retain what I already entered? I thought setting the dataset to the session did this.
Current code:
private void Button2_Click(object sender, System.EventArgs e)<br />
{ <br />
<br />
DataGridItemCollection items = dgParts.Items;<br />
<br />
<br />
int rows = items.Count;<br />
if (rows == 0)<br />
{<br />
<br />
BindData();<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow();<br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
<br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
Session["test"]=ds;<br />
}<br />
<br />
else<br />
{<br />
ds = (DataSet)Session["test"];<br />
DataTable dt = ds.Tables[0];<br />
DataRow row;<br />
row = dt.NewRow(); <br />
strPartNumberInputReference = txtSearchPart.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
}<br />
<br />
}
Thanks again for your help!
|
|
|
|
|
It could be that you're missing
DataTable dt = ds.Tables["Rest"];
in the block following the else statement.
|
|
|
|
|
A few days ago I posted a message wondering if anyone had any info on a problem with the ListView in .NET 2.0. The backcolor would disappear when scrolling or selecting and wouldnt come back until the form lost focus and got it back. (As a side note, calling Invalidate() or Refresh() on the ListView caused ALL items to lose color.) The solution turns out to be simple. In the Main method, just add Application.EnableVisualStyles(). HTH anyone with the same issue.
Aaron
|
|
|
|
|
I'm developing a plugin architecture for an application that will translate some database schema to an XML document that complies with an XML schema. Most of my architecture has been modelled after the article posted by 'Redth' here: http://www.codeproject.com/csharp/pluginsincsharp.asp
I'm able to call some methods from the host so long as those methods do not reference any classes outside of the namespace that the host sits in. Once I attempt to call methods from a namespace that it outside of the host (ie the namespace that contains all the data binding for the XML schema that I need to use) I get a MissingMethodException. All the correct references are in place and everything builds fine, yet the plugin can't access any of the classes in the data binding layer at runtime.
Any suggestions? Thanks!
|
|
|
|
|
Hi all,
I am planning to make a simple proxy server and i have been trying to retrieve the contents of a web page via Socket and send the display (NetworkStream.Flush) to a client browser. the html contents are being displayed properly but the images are not there. even the httpWebResponse.ContentLength shows the length of html content only.
someone plz tell me how to retrieve the images along with html using HttpWebRequest so that the page displays properly.
Thanks in advance.
|
|
|
|
|
If read through these forums you will see that re-asking the same question, even if it is re-phrased, doesn't help.
|
|
|
|