|
that all depends upon ur need that what scope of accessibilty u want to provide to particular object or member,u can find it in any basic book on c#.
rahul
|
|
|
|
|
Your problem is scope. You created the object in create_click, thus it goes out of scope when the method terminates. You can create a member of the application of type Animal. Then instantiate the object in the create click. The object will have a global scope within the current form.
|
|
|
|
|
Thank you for this, I will give it a go tonight
All the best
Phill
|
|
|
|
|
Hi, I have tried to understand by what you meant by "You can create a member of the application of type Animal", please excuse me if it is a really simple thing you have suggested.
Is it possible to explain in a little more detail?
Very Much Appreciated
Phill
|
|
|
|
|
namespace WindowsApplication1
{
public partial class frmAnimal : Form
{
public frmAnimal()
{
InitializeComponent();
}
...
private Animal myAnimal;
public Animal MyAnimal
{
get{ return myAnimal; }
set{ myAnimal = value }
}
}
}
Then in your form's create method, just create the instance.
MyAnimal = new Animal;
Then it will be accessible to the entire form.
|
|
|
|
|
Thankyou for your example it has helped me a lot,
I have been practicing different examples of how to create the methods just using the console instead of jumping straight into forms and I am finding it easier to grasp the concepts
Thanks
Phill
|
|
|
|
|
Hi,
I've created a custom text control, and when i set the BorderStyle to Fixed3d, as you'd expect I get a 3d border. Trouble is, with the XP theme on, other text boxes have a flat blue border when set to fixed3d, which is what I want mine to mimic.
I've looked at the extended styles on a normal text box, and it's got WS_EX_CLIENTEDGE set, which is the same as my custom text box.
does anyone know how to get this border behaviour.
Cheers
Simon
|
|
|
|
|
Hi,
I just picked up a special interest in C# and the .NET, but having problems selecting a text for study. Can anyone with much experience advise as to the best and most comprehensive book to use for C# and the .NET for individuals with little or no programming experience?
I'm also into PHP and MySQL. I heard that the Visual Studio.Net/Visual Studio support the development of PHP codes. Is this true?
|
|
|
|
|
Wrox is very good and complete, but very boring as well...
The microsoft books weren't bad for beginners and are less boring, but they don't go in dept at all...
hope this helps...
|
|
|
|
|
The APress books are pretty good as well.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You won't find a book that's both good for programmers with little or no programming experience and comprehensive.
However, the Micrsoft Press books for the Visual Studio Express editions might be worth a look.
Kevin
|
|
|
|
|
|
Wrox has a series of books that start at the beginner level, and show a "road map" of books to help you progress in your task.
|
|
|
|
|
How can I detect the sound device?
Which namespace is required?
and what type is its input and output? is it binary?
Thanks for answer.
Bahman
|
|
|
|
|
Hi dudes,
could you Please help me with a code, to log errors into a text file using log4net in c#.. would appreciate your help if u help me asap.
many thanks
Thanks & Regards,
Vinothkumar V
|
|
|
|
|
Nothing in the documentation?
Kevin
|
|
|
|
|
Log4Net comes with comprehensive documentation. Your answer lies there.
|
|
|
|
|
Hi dudes,
could you Please help me with a code to log errors into a text file using log4net in c#.. would appreciate your help if u help me asap.
many thanks
Thanks & Regards,
Vinothkumar V
|
|
|
|
|
There is no need to post a question multiple times.
|
|
|
|
|
Hello,
I'm trying to download files from a FTP located on the PC of a colleague of mine (in the same network of the company). I succeded in dowloading the files on my hard disk and now i have to delete these file from the FTP. I get the errror: "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)." The colleague with the FTP tried also to delete it with this code and he received the same error.
I don't know what i'm doing wrong, so please, if you have any idea that might solve this problem, please reply.
Thanks a lot!
The code i wrote is:
public class TransFile
{
public void Download(string destinationFile, Uri downloadUri, string user, string password)
{
try
{
if (downloadUri.Scheme != Uri.UriSchemeFtp)
{
throw new ArgumentException("URI is not an FTp site");
}
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(downloadUri);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
while (reader.Peek() != -1)
{
String file = reader.ReadLine().ToString();
System.Uri uriData = new Uri(downloadUri + file);
DateTime dataLastMod = new DateTime();
dataLastMod = GetDateTimestampOnServer(uriData);
if(DateTime.Compare(DateTime.Now, dataLastMod.AddMinutes(10))>0)
{
if (user != null)
{
ftpRequest.Credentials = new NetworkCredential(user, password);
}
try
{
WebClient wclient = new WebClient(); wclient.DownloadFile(downloadUri+"//"+file, destinationFile);
}
catch (Exception ey)
{
throw ey;
}
try
{
DeleteFis(uriData);
}
catch (Exception ex)
{
FileInfo fl = new FileInfo(destinationFile);
fl.Delete();
throw ex;
}
}
}
}
catch (Exception ev)
{
throw ev;
}
}
public static DateTime GetDateTimestampOnServer(Uri serverUri)
{
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
throw new ArgumentException("URI is not an FTp site");
}
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.Method = WebRequestMethods.Ftp.GetDateTimestamp;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
DateTime data = new DateTime();
data = response.LastModified;
}
public bool DeleteFis(Uri serverUri)
{
try
{
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return false;
}
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.Method = WebRequestMethods.Ftp.DeleteFile;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
}
catch (WebException e)
{}
return true;
}
}
|
|
|
|
|
Dear all,
i am using vs2005.i have developed windows application.in that i have refered the text file using the executable path.when i run the application in my system it was working fine.but after creating setup using clickonce deployment,if i refer the file in client it shows error.somebody told we want to add those file as datafile using mageui utility.i donot know how to do that.if any one knows please tell me.
Thanking you
i have using like this helpProvider1.HelpNamespace = Path.GetDirectoryName(Application.ExecutablePath)+"\\sample.txt";
-- modified at 6:04 Friday 10th November, 2006
|
|
|
|
|
how can we set the maximum value in NumericUpDown,while using a keyBorad
My small attempt...
|
|
|
|
|
on NumericUpDown keypress event u can check the maximum value and stop the user
to enter value greater than that by following way
if(numericUpDown1.Value >= maximumvalue)
e.Handled=true;
rahul
|
|
|
|
|
Thanks for ur reply,but it wil not work.After each keypress control will go the left side.so we cant enter the number
My small attempt...
|
|
|
|
|
Hi,
Using Visual Studio 2003.
I'm calling a method located in Form1 from Form2.
I'm doing it by creating an object of Form1
Form1 myForm1 = new Form1();
myForm1.MethodToCall();
I originally made the method static (to call on it), but this method calls on another method and variables, so it seemed easier to create an object in Form2.
The problem I'm having is:
In the method I'm calling, I have code to change the text of a label control.
The label text is not changing and it looks like I need to declare
the label as "static"... is this correct? If so, is it possible to set this (label to static) in Visual Studio Properties Window, or do I need to create the label code myself in order to use static on a label?
thanks,
Ron
|
|
|
|