|
For one, you need to have the CDO component installed. The easiest way on Windows 2000, XP, and Windows Server 2003 is to install the SMTP services. Also, the SMTP server must relay for a particular domain. In your case, you must relay for hotmail.com.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I was wondering if you can set a hidden value (would this be called a SelectedValue?) to each row in ListView? I'm populating the ListView from a DataSet. I want to be able to click on a row and have a form come up and ask for edit/delete this row (which would really update the DataSet and then reload the ListView to show the changes). Of course in order to do this, I need to have a corresponding ID for each row in the ListView that's retrievable from the selected row.
Thanks,
Ron
|
|
|
|
|
I faced with this problem not so long... Well, I created a hashtable and set keys from 0 to ListView.Count, and values were set just like in ListView, and on_klick I looked through hashtable and delete item that I need.
xedom developers team
|
|
|
|
|
Hi Ron,
Each ListViewItem has a Tag property which can be used for storing anything you need. In your case you could associate an ID or a datarow object with it.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
Thanks Serge!
Works great!
Ron
|
|
|
|
|
I created two forms: MainForm has a textbox tbBox1. I clicked a button btnOpen to open the second form (named Form2). Now I want to get or set the value of tbBox1 from the second form by clicking a button btnAccess. How can I do it? The MainForm was opened by the standard "Application.Run(Form MainForm);" and the second form was opened by "Form2 a = new Form2(); a.Show();" in btnAccess's OnClick event. I have made tbBox1 public but I couldn't access the instance of MainForm. The MainForm class' instance (an object) has no name when opened from Application.Run. Please help.
|
|
|
|
|
1. in form2, declare a member System.Windows.Forms.Form pForm;
2. overload the Form2's constructor
public Form2(System.windows.Forms.Form aForm)
{
pForm = aForm;
}
now you can acess Form1 like this.
pForm.xxxButton.Text = "test";
try it.
nhi
|
|
|
|
|
of course,when you create Form2 in form1 ,you should pass itself to the form2's contructor like
Form2 frm = new Form2(this);
frm.Show;
nhi
|
|
|
|
|
Make a function in your second form that takes a Form1 object as a parameter. Then pass "this" as the parameter from the first form
Form2 a = new Form2();
a.myFunction(this);
...
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thank you all. I got it work now. I declared the textbox in MainForm as public so that Form2 can get to it. Thanks again.
|
|
|
|
|
Right now I'm writing a wallpaper changing application to run in the systray. The application works great. The app went together really quickly and easily using the .NET framework. However, since it is a systray app.... I want it to be as small as possible in memory.
Just running the app (not even connecting to the web or working with GDI+ for imaging) it sits at about 12M in memory with 5M virtual memory. This is the release version of the code.
Is there anything I can do to reduce the footprint? I liked the speed of development, but I don't know if it is worth almost 20M in memory.
Thanks,
Dave
|
|
|
|
|
Take a look at System.Diagnostics.Process.MaxWorkingSet and MinWorkingSet properties.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thanks, I looked but the min is set to 204,800 and max is set to 1,413,120. I'm not exactly sure what these values are expressed in... bytes, KB,megs, pages, something else?
It doesn't look like they are that large. How do I change the values?
When I try to set the value I get a:
Cannot implicitly convert type 'int' to 'System.IntPtr'.
Thanks again,
Dave
|
|
|
|
|
That's the .NET Framework for you. Depending on what Types you use, the defining assemblies are loaded into memory. This can produce a large footprint, and there's really nothing you can do about it.
As far as setting the MaxWorkingSet , you have to assign it new IntPtr(someIntOrLongValue) , since the property type is an IntPtr . You should read the documentation about the Process.MaxWorkingSet property. You can only set this to a value that still allows all the assemblies to be loaded into memory.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
.NET DataGrid drawing header text according to it's DataGridColumnStyle Alignment.
I want to draw header text at center of column.
also, i want to draw image at header.
I tried to override OnPaint Method. But it is not good way.
Is there any simple way to do that using window message and functions?
i have to finish this job quickly.
Help me!
thanks to regards.
SeungPil Lee
|
|
|
|
|
The Paint method is called to draw your contents, not the header. You can align the header - though it'll align the contents as well - by setting the DataGridColumnStyle.Alignment property to HorizontalAlignment.Center .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I copy the MSDN demo source code and run it. but nothing happens.
Does it need other system settings? or what?
thanks!
NHi
|
|
|
|
|
You mean from the FileSystemWatcher class documentation? Did you specify a directory to watch? The source code is correct.
Instead of just copying and pasting source code, read about the class, understand it, then write a sample of your own. Copying and pasting source code won't teach you anything.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Instead of just copying and pasting source code, read about the class, understand it, then write a sample of your own. Copying and pasting source code won't teach you anything.
Heath, I voted you a five and thought you might want to include this in your sig. Might save you some keystrokes.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
Thanks.
Yeah, I think I understand it correctly. I noticed all the control's attributes and functions. The wathcher control is quite well wrapped and easy to use, I consider. Copy and paste source code in MSDN document is the last step I tried. The following is the sample.
public class Watcher
{
public static void Main()
{
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "e:";
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
Console.WriteLine("Press \'q\' to quit the sample.");
while(Console.Read()!='q');
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
}
}
fay
|
|
|
|
|
OK, I got the answer now.
The only one point caused it did not work is:
watcher.Path = "e:";
the correct code is
watcher.Path = "e:\\";
other similar code works as well when modify them as above.
the conclusion is: The FileSystemWatcher's Path attribute needs a "\" at the end.
fayth
|
|
|
|
|
I hate to chase all the way the latest technologies, this is why while others are switching their lanes to Java or C#, I'm still a C++ programmer. But now I think it's time for me to change, and I'll have to chose among Java and C# my next generation language.
What's your opinion ? I think maybe this is wrong place to ask, cuz it's C# place...
Horace3801
|
|
|
|
|
why one of them?
why not both of them?
It is a tool by itself. I utilize either of them depending on the project.
nhi
|
|
|
|
|
Are you sure that you'll stick to windows during the next few years?
Yes: C# !
No: Java !
Do you code desktop applications, or web applications?
Desktop: C# !
Web: Java !
If you are not sure about what you will use your new language for, I suggest you learn Java. Switching from Java to C# later on is easy, because C# is not much more than a combination of Java and C++.
|
|
|
|
|
I'd have to say that I disagree with your web application recommendation. I don't think a desktop vs. web argument can be made unless you need to be flexible with the client/server OS.
|
|
|
|