|
This[^] link may provide an answer.
/ravi
|
|
|
|
|
I have created a class called BankAccount. the samle is a floows
public delegate void myEventDelegate();
class BankAccount
{
public static long Balance;
public event myEventDelegate myEvent;
public void WithDraw(long amount)
{
Balance -= amount;
myEvent();
}
}
i then wired my event in the frm load to an event handler "OnWithdraw"
i also a textbox where by i subtract the money to be withdrawn from the account. The method display an event to the user when the account bal < 0;
when i run the program i receiven a NullArgumentException error on the "myEvent" int BankAccount class
how do i make my event work?
|
|
|
|
|
You should never call a delegate without firstchecking if it is null.
Obviously your event wiring code is broken. You need to post it for us to comment further. Have you checked in the debugger that it gets wired up ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sorry for that. this is my first time posting.
//From BankAccount.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Delegates_and_Events
{
public delegate void myEventDelegate();
class BankAccount
{
public static long Balance;
public event myEventDelegate myEvent;
public void WithDraw(long amount)
{
Balance -= amount;
myEvent();
}
}
}
//from frmMain.cs
private void Form1_Load(object sender, EventArgs e)
{
BankAccount myAcc = new BankAccount();
BankAccount.Balance = 1000;
myAcc.myEvent += new myEventDelegate(OnWithDraw);
}
public void OnWithDraw()
{
if (BankAccount.Balance < 0)
{
MessageBox.Show("Account Overdrawn");
}
}
I also have a textbox where i am getting the value which i subtract using the following
private void btnWithDraw_Click(object sender, EventArgs e)
{
BankAccount myAcc = new BankAccount();
myAcc.WithDraw(long.Parse(txtAmount.Text));
txtBankBalance.Text = BankAccount.Balance.ToString();
}
|
|
|
|
|
I am trying to import a dbase file in to sql . but when an empty record comes the programme stops reading
when empty record comes first , program does not read the table at all.
i use the following connection string
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBFpath + ";Extended Properties=dBase III
rkherath
|
|
|
|
|
Hello Friends,
I am developing C#.NET windows application i want that what ever font size i select from combobox the size of the font changed to that size..
And also according to the font size the size of the control also resized...
Please help me...
Bye
Thanks in Advance
|
|
|
|
|
The easiest way is to set the AutoSize property to resize the control automatically when the text size changes and set the Font property of the control to the font you desire.
button1.Font = new Font("Arial", 18);
Eslam Afifi
|
|
|
|
|
hi
i have process.StartI("projet1.mpp") in my code
sometimes this code run successfully and run the msp projects
but sometimes this code contain error
in trace code process is null and i dont know thats reason
can any one tell me thats reason and its solution?
thanks alot
modified on Monday, February 18, 2008 11:58 PM
|
|
|
|
|
Hello everyone.
At first you might be thinking so what is the big deal in implementing paging.
But actually its not that simple. Here is what i have to implement.
The main parent window where the user gets the records in a datagrid based on dates params in the following format
email - firstName - lastName
By click on email a pop up window displays the detail of that record. Its the same concept as master detail.
Ok now here is the tricky part. i want to have a prev and next button in the pop up window.
So the user can move back and forth to see next or previous record in the pop up window with out closing the pop up and then clicking on the next record in the main parent window to see the detail.
Any Ideas
Thx
|
|
|
|
|
You can use a delegate to get the next id from the main window in your popup.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for reply.
Can you explain it in a liitle more detail.I would really appreciate if you can direct me to the relevent ariticals or anything that would give more more detailed insight on the problem.
Thax
|
|
|
|
|
Hi I would like to have C# with ASP.NET 2.0 code to allow members to message each other within my website. Its a dating website in the very beginning stages.
Can anyone help? I'm not too good at C#.
|
|
|
|
|
Judging by your question posted one minute earlier, you really are at the very early stages. I'd leave things such as internal emailing until you have a better comprehension of what you want to achieve and understand at least some of the basic steps. I'd suggest you put this in a 'ToDo' file for later.
By the way, cross posting is frowned upon here and you're not likely to get help by doing it. If it's an ASP question , ask there. If C#, ask here. If you're not sure then post in either, but not both
Dave
|
|
|
|
|
Ok Thanks. Dave. I really wasn't sure which topic that belonged in. Do you think that would be C# then, or ASP.NET in reference to internal email messaging?
|
|
|
|
|
I am coding in ASP.NET 2.0 and trying to figure out how to gather info users can type onto the page and have that pass the data over to the 2nd page, and then finally gather all those fields and dynamically create a profile page that will be saved as a member00001.htm, member00002.htm for the 2nd user, and so on.
Can anyone help?
|
|
|
|
|
There are so many examples of how to create form fields and transfer data from page to page I find it difficult to believe even a beginner couldn't figure this out.
At least try something, then ask for help.
only two letters away from being an asset
|
|
|
|
|
since there are so many examples you are aware of, could you post some links? Is that too much to ask?
|
|
|
|
|
|
|
hello everyone:
I need to parse a complex xml file into meaningful controls. Here is what the XML file looks like:
<Controls>
<group>
<field name="CheckBox1" y="34.925" x="3.175" w="28" h="6">
<ui>
<checkButton>
<border>
<css style="single"/>
<fill/>
</border>
</checkButton>
</ui>
<font face="Arial"/>
<padding leftInset="1" rightInset="1"/>
<textAlign vAlign="middle"/>
<value>
<integer>0</integer>
</value>
<label placement="right" reserve="21">
<textAlign vAlign="middle"/>
<font face="Arial"/>
<value>
<text>Select Check Box</text>
</value>
</label>
</field>
<field name="textBox" y="3.175" x="3.17" w="62" h="9">
<ui>
<textBox>
<border>
<css style="">
</css>
</border>
<margin/>
</textBox>
</ui>
<font face="Arial"/>
<margin topInset="1" bottomInset="1" leftInset="1" rightInset="1"/>
<textAlign vAlign="middle"/>
<label reserve="25">
<font face="Arial"/>
<textAlign vAlign="middle"/>
<value>
<text>textbox label</text>
</value>
</label>
</field>
</group>
</Controls>
Can you help me figure out how to read this xml and come up with:
TextBox txtBox = new TextBox();
txtBox.name = "txtBox";
txtBox.Location = new Point(3,3)
txtBox.Size = new Size(9, 6);
...
and so on .. hopefully you get the idea of what I am trying to do.
I would really appreciate your help. Thanks.
|
|
|
|
|
With an XmlDocument
or do you want to use XSLT to transform it into a CS file?
|
|
|
|
|
Well not sure what approach will be the best.... so looking for advice from you guys.
Also how can I use XmlDocument to accomplish what I want? I havent worked much with xml to begin with a code example will help. Thanks.
|
|
|
|
|
For part of my reporting system I do something similar, but much simpler:
<Report>
<Parameters>
<Period DataType="System.String" Align="Left" Null="false" />
<StartTime DataType="System.DateTime" Align="Left" Null="false" Format="yyyy-MM-dd HH:mm" />
<EndTime DataType="System.DateTime" Align="Left" Null="false" Format="yyyy-MM-dd HH:mm" />
</Parameters>
...
from this I can populate a simple WinForms dialog with appropriate controls so the user can enter values for running the report, but I don't control font or position.
Reading XML with an XmlDocument is very easy -- I'll leave the research to you.
Once the document is read you can enumerate the group and field elements -- I'll leave the research to you.
With each field, you want to translate the ui element's child's name to determine which type of control to instantiate. From there, you can set the properties and add the control to the form.
Where does the XML come from? Do you have control over the schema of the XML? I think I'd make it simpler if I could.
|
|
|
|
|
XML is coming from a Legacy system which is pushing out xml for dynamic form generation.
I understand the "read the xml and iterate through the nodes concept", however, I was wondering if there is a better/simpler way, then just looping through the nodes, like maybe using Xpath or what have you. But thanks for the help I appreciate it.
|
|
|
|
|
hi
is that anyWay that convert html docs (include images,styles,...) to a single xml file ?
thanks.
|
|
|
|