|
You need to include the Windows.Forms ( from memory ) dll so you have access to the library. IT's just not going to be there by default, in a library project.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I came across the requirement for a project that I was working on, I have to add unlimited 'Adress(name address,city,zip)' to database when user clicks add button.
i have to delete the controls when he clicks delete button and have to reshuffle the the locations of other controls...
vidya K.A
|
|
|
|
|
You can add as many controls as you like to a form, just add them to the Controls collection.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Try creating a user control with the Address(name address,city,zip) info on it.
Then you add\delete the just the user control each time.
This way you only need to manage 1 control per address...
Cheers
|
|
|
|
|
Has anyone got any sample code for conway's game of life? Any help would be much apppeciated, thank you
|
|
|
|
|
Have you already looked here[^]?
Robert
|
|
|
|
|
How to get user`s login time?
I don`t mean the time when the machine has been turned on, just the time when user has logged to Windows.
|
|
|
|
|
This article might help:
http://weblogs.asp.net/ralfw/archive/2004/01/04/47442.aspx[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for effort but don`t you have some C# code?
|
|
|
|
|
-Yoyosh- wrote: Thanks for effort but don`t you have some C# code?
Good grief man. Do you want blood?
using System;
using System.Runtime.InteropServices;
using System.Collections;
namespace UserLastLogin
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
UserLoginDetails details = new UserLoginDetails();
ArrayList list = details.Users;
foreach (UserLastLogin.UserLoginDetails.UserLastLogon users in list)
{
Console.WriteLine("User {0}, last logged in on {1}\r\n", users.UserName, users.LastLogon);
}
Console.ReadLine();
}
}
public class UserLoginDetails
{
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct USER_INFO
{
public string Name;
public string Password;
public int PasswordAge;
public int Priv;
public string HomeDirectory;
public string Comment;
public int Flags;
public string ScriptPath;
public int AuthorisationFlags;
public string FullName;
public string UserComment;
public string Param;
public string Workstations;
public int LastLogon;
public int LastLogoff;
public int AccountExpires;
public int MaximumStorage;
public int UnitsPerWeek;
public byte LogonHours;
public int BadPasswordCount;
public int NumberOfLogons;
public string LogonServer;
public int CountryCode;
public int CodePage;
}
[DllImport("Netapi32.dll")]
extern static int NetUserEnum([MarshalAs(UnmanagedType.LPWStr)] string servername,
int level,
int filter,
out IntPtr bufptr,
int prefmaxlen,
out int entriesread,
out int totalentries,
out int resume_handle);
[DllImport("Netapi32.dll")]
extern static int NetApiBufferFree(IntPtr Buffer);
public class UserLastLogon
{
private string _userName;
private DateTime _lastLogon;
internal UserLastLogon(USER_INFO info)
{
_userName = info.Name;
_lastLogon = new DateTime(1970,1,1,0,0,0,0).AddSeconds(info.LastLogon);
}
public string UserName
{
get { return _userName ; }
}
public DateTime LastLogon
{
get { return _lastLogon ; }
}
}
private ArrayList _users = new ArrayList();
public UserLoginDetails()
{
IntPtr bufPtr = new IntPtr();
int entriesRead;
int totalEntries;
int resumeHandle;
try
{
NetUserEnum(null, 2, 2, out bufPtr, -1, out entriesRead, out totalEntries, out resumeHandle);
if (entriesRead > 0)
{
IntPtr iter = bufPtr;
for (int i = 0; i < entriesRead; i++)
{
_users.Add(new UserLastLogon((USER_INFO)Marshal.PtrToStructure(iter, typeof(USER_INFO))));
iter = new IntPtr(iter.ToInt32() + Marshal.SizeOf(typeof(USER_INFO)));
}
}
}
finally
{
NetApiBufferFree(bufPtr);
}
}
public ArrayList Users
{
get { return _users ; }
}
}
}
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Can you do my homework too?
|
|
|
|
|
ednrgc wrote: Can you do my homework too?
Sure - bring it on .
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
The menu item freezes for a few seconds each time it is clicked on. It basically brings up another form i.e. form2. In form2 (load event) data is retrieved from a database.
The menu in form1 freezes for a few seconds until form2 is displayed. Is it possible to avoid the menu to freeze?
Thanks
|
|
|
|
|
The time is being taken up by the database retrieval. One way to get around this problem is to make the database retrieval run on a different thread to the load and then display the data in the main UI when it has finished. Have a look at BackgroundWorker to get an idea as to how this could work.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I want to send email from a windows application.
I tried some code but of no use....
here's the code that i tried...
MailAddress mailAddressFrom = new MailAddress("xyz@abc.com");
MailAddress mailAddressTo = new MailAddress("pqr@abc.com");
MailMessage message = new MailMessage(mailAddressFrom,mailAddressTo);
message.IsBodyHtml = true;
message.Subject = "HI";
message.Body = "HELLO, HAPPY NEW YEAR";
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "localhost";
try
{
smtpclient.Send(message);
}
catch (Exception ke)
{
string strMsg = ke.Message;
MessageBox.Show(ke.Message);
}
i get the exception saying "The operation has timed out"
can anyone tell the correct way?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Check your launch and activate permissions for 'Network Services'.
SkyWalker
|
|
|
|
|
Whr do i find these settings?
But if my application is used by some users they will also need to set the above settings...
isn't there any generic way to send emails from a windows application in C# .Net?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Maybe you can find a starting point here[^]
SkyWalker
|
|
|
|
|
hi everyone
well I just wanna know how can we get the names of all availabe sql server 2000's available on the single PC or a network.
I'm working in C# 2.0 windows Forms application
Thanks in advance
Rocky
|
|
|
|
|
There is already an article available.
http://www.codeproject.com/cs/database/SubmitSQLInfoEnumerator.asp
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
looks preety helpful thanks...
|
|
|
|
|
Hi All,
Warm New Year Greetings. Can anyone of you tell me how to get the application path during run time in C#. Please do reply.
Regards
Babu
|
|
|
|
|
If u want to get the path of your application, then use the below code:
System.Reflection.Assembly.GetExecutingAssembly().Location
Thanks & Regards,
Venkat
|
|
|
|
|
|
Happy New Year to you, too!
Use Application.ExecutablePath and Application.StartupPath , or use the System.Reflection namespace to get the properties of your assembly: System.Reflection.Assembly.GetExecutingAssembly.Location
SkyWalker
|
|
|
|