|
Oh i found it nevermind,.
What do you mean the constructor? In my case, Form1_Load?
|
|
|
|
|
in Form1.cs
namespace yourNameSpace
{
public partial class Form1 : Form
{
public From1(string[] myArgsFromProgramDotCS)
{
InitializeComponent();
}
}
}
i suggest you get and read a beginners book, hope this helped
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Environment.CommandLineArguments IIRC
|
|
|
|
|
|
Example is what? It shows the same stupid approach previously mentioned.
|
|
|
|
|
Why is it stupid?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Giorgi Dalakishvili wrote: Why is it stupid?
Because the correct way (Environment.GetCommandLineArgs() ) is much simpler, and not error prone.
|
|
|
|
|
OK, you can add the params parameter to the main method. But to pass them on to the main form you better give the main form a string[] property. Or if you want to use the main form's constructor, be sure not to use the given parameterless constructor, but a second one (which has to call InitializeComponents as well), or the bloody designer will give you hell.
By the way, this is just one of those things usually omitted by beginners' books and unmentioned in MSDN, so I think it's a fair question.
|
|
|
|
|
Frank Horn wrote: OK, you can add the params parameter to the main method. But to pass them on to the main form you better give the main form a string[] property. Or if you want to use the main form's constructor, be sure not to use the given parameterless constructor, but a second one (which has to call InitializeComponents as well), or the bloody designer will give you hell.
Why? There is a perfectly good method for that already. I will mention it again: Environment.GetCommandLineArgs() , it return exactly the same args that was passed to Main (in fact Main does not even need the string[] args parameter).
Frank Horn wrote: By the way, this is just one of those things usually omitted by beginners' books and unmentioned in MSDN, so I think it's a fair question.
It is well documented in MSDN. Getting to read MSDN inside out takes a long time! You just need to know what you are looking for
|
|
|
|
|
You're right of course, leppie. No need to fiddle with the Main() procedure. Should have thought of that. Anyway, I wanted to warn against modifying the form constructor provided by the VS designer cause that's a classical beginner's trap. You take away the standard constructor and can't retrieve your form layout. Happened to me too in my time.
|
|
|
|
|
Hi all,
My requirement is to show a fixed a non editable form in left protion of a form and the right part contains some editable fields which will be filled on the basis of the the form on the left side of the main form.
I have used pannals for seperation of the main page in two but i am unable to find the zooming option for the left pannal(that non editable form) for the better viewing.
Can any body help me with out with concept of zooming of any page in windows application using VS .Net 2005?
Thanks in Advance
Ankur
|
|
|
|
|
Lets say i have a custom control with the following private variable and property
private DateTime myTime = new DateTime();
public DateTime MyTime
{
get
{
return myTime;
}
set
{
myTime = value;
textBox.Text = myTime.TimeOfDay.ToString();
}
}
does the property(specifically the set block) get run upon construction of the control?
Cuz what happening is the textBox is Showing 00:00 at startup and its supposed to be blank...
any ideas?
Thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: private DateTime myTime = new DateTime();
HarveySaayman wrote: Cuz what happening is the textBox is Showing 00:00 at startup and its supposed to be blank...
And that's exactly what you told it to do! I am sure you can see the error now
|
|
|
|
|
hey leppie
i get that the variable is 01/01/0001 00:00, but what i dont understand is the set block executing on construction(assumption)...
the Variable should be 01/01/0001 00:00 but in the TextBoxTextChanged_Handler i have something like this...
TextBoxTextChanged(object sender, EventArgs e)
{
try
{
MyTime = DateTime.Parse(((TextBox)sender).Text);
}
catch
{
}
}
so then ONLY when a user changes the text value AND it can be parsed to a DateTime will the property change.
but it seems like the initial 01/01/0001 00:00 value of myTime somehow gets written in my textbox
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
It is really ASP.NET, but you forgetting to save the DateTime in ViewState. Hence it will be reset everytime.
|
|
|
|
|
In C# all variables have an initial value of zero, which results in the date and time you're getting. I don't understand how it gets written into the text box.
So, put a break point in the set method of your property, run the code, and look at the call stack to see what is calling your set method. (This is one of the advantages of properties over public variables; it's easy to inspect what's changing the value.)
|
|
|
|
|
If you look in the Form's designer.cs file you'll see that it is initializing the MyTime public property which is why the setter is being called.
You could remove that line from the designer file but it'll keep getting put back when any changes get made to that form.
Dave
|
|
|
|
|
OMG your right this screws my logic around quite a bit!
is there any way that you can think of around this? accept removing the lines...
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
A bit dirty but maybe have a private bool updateEnabled = false; and put the code in set inside
if(updateEnabled)
{
}
else
{
updateEnabled = true;
}
Dave
|
|
|
|
|
thanx, i was thinking something similar... like
public DateTime BreakStart
{
get
{
return breakStart;
}
set
{
breakStart = value;
if (breakStart != new DateTime())
{
mtxtBreakStart.Text = breakStart.TimeOfDay.ToString();
}
}
}
DaveyM69 wrote: A bit dirty
i agree and my solution is dirty as well, but i don't see any other way... the main reason is cuz my drawing methods bool variables (like DrawData(), etc) is set to true if certain groups of textBoxes can be Parsed to DateTime successfully. That's why i cant have the 00:00 unless the user specifically entered it, the drawings get all messed up.
i thank you again for your help, i dont think i would have found the problem without you...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
No problem
Dave
|
|
|
|
|
Hi,
Am working with Windows application in VS 2008,where i need to customize the set up wizard.Is that possible?If so,what are the needed steps to be do the customizing process?
Regards,
Priya
|
|
|
|
|
I have a textfile(html document) that i want to parse some specific information from. Is there a way built in to C# that enables me to look for a specific starting pattern and ending pattern in a text document and then read that line by line?
|
|
|
|
|
Oh, there is a wonderful tool [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can someone tell me or relate me to an article of how to create a splash form for windows application please? thank you
|
|
|
|