|
I am trying to refer some code at
http://mokhan.ca/blog/2007/09/25/SALES+TAXES.aspx[^]
I couldnt understand the use of delegates as below:
private double CalculateAmount( ) {
double amount = 0d;
Summary( delegate( ITax tax ) { amount += tax.Amount; } );
return amount;
}
How and why its being used here????
~AHAGeek
|
|
|
|
|
Summary takes a delegate to calculate tax, however, the Summary method seems out of place since there is nothing to provide a return value to amount meaning the only possible action the summary method can perform is to sum all of the applied taxes.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
they are in a different class named baglanti
public GroupBox gb;
public void gbColor(GroupBox gbT)
{
gb = gbT;
gb.MouseClick += new MouseEventHandler(gb_click);
}
private void gb_click(object sender, EventArgs e)
{
gb.BackColor = Color.Red;
}
in other class i use this to add gb_click event to the groupboxes
clsBgl.gbColor(groupBox1);
clsBgl.gbColor(groupBox2);
clsBgl.gbColor(groupBox3);
it always execute the lastone, when i click on groupbox3 its color is changing but others stay same.
thanx for your helps..
thanks for everything i have...
|
|
|
|
|
TALHAKOSEN wrote: clsBgl.gbColor(groupBox1);
clsBgl.gbColor(groupBox2);
clsBgl.gbColor(groupBox3);
you are overwriting the variable (gb) so the behavior is expected
instead create a new instance of the class for every groupbox
gb1 = new clsgbl
gb1.gbcolor(groupbox1)
gb2 = new clsgbl
gb2.gbcolor(groupbox2)
gb3 = new clsgbl
gb3.gbcolor(groupbox3)
(not shure about the syntax been a while since I done c#)
|
|
|
|
|
Thx for your help and i found how to to do that exactly
public void gbRenk( GroupBox gb)
{
gb.MouseClick += new MouseEventHandler(gb_renkAl);
}
private void gb_renkAl(object sender, EventArgs e)
{
((GroupBox)sender).BackColor = Color.Red;
}
thanks for everything i have...
|
|
|
|
|
I want to upload a textfile created in my server to an ftp server thru C#.net code or FtpWebRequest.........
|
|
|
|
|
is the destination folder is a share folder or network mapped folder??
|
|
|
|
|
Hi,
I have the following scenario for a social networking site I am working on.
Users create accounts in the site and then can edit their details etc. They can also have their public facing page (which will be seen by others when they click on their name etc).
Example User A signs up and then creates his public page e.g. site.aspx
I want that the user can customise this page using webparts and .net personalisation so that his changes made (like themes or webparts) can be seen by User B.
I first got it working by letting the user modify his own page but the changes reflected only when he logged on.
Then I got it working by using the following:
<webParts>
<personalization>
<authorization>
<allow users="*"
verbs="enterSharedScope"/>
</authorization>
</personalization>
</webParts>
However, with the second approach now anyone could edit his page and save the shared view as all users will have permissions to amed their pages.
I am trying a third solution by creating folders for users and then copying a default.aspx and web.config file in it, thinking there may be a way this way... but am stuck.
The users are created using asp.net membership with additional details held in custom table.
Any ideas on how to implement this functionality of user customisable page where customisations can be seen by others as well as him.
Thanks,
Adeel
|
|
|
|
|
I have started a thread in the SQL Forum asking about experiences others have had using CLR-based SPs in SQL Server. Rather than do a complete cross-post and end up with two threads, I would like to ask any C# developers here that have something to offer to the discussion to please go over there and contribute:
http://www.codeproject.com/script/Forums/View.aspx?fid=1725&msg=2777359[^]
Thanks!
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hay ..
I have a table for eg , emp with the next data :
ID Name
1 AA
2 BB
3 CC
I fill the combo box as the next :
<br />
combobox.ValueMember=ID;<br />
combobox.DisplayMember = Name;
the user see Name but the application save ID in the database .
then when I navigate records , sure the combobox dispaly the ID which is saved on database ,,
I tried to do that :
combobox.SelectedValue = combobox.Text;
but it didn't give me the required result..
I want to view the Value (Name field) instead of text (ID field)
thanks
jooooo
|
|
|
|
|
Good Afternoon All
I have the Followiong code that is running Perfect, but it usually get input from the users as the name of the process to kill, now i want to create a Service that will kill a certain Process everytime its running. How can i create a Windows Service based on this Code
public bool FindAndKillProcess(String name)
{
Boolean Bolres = false;
Process[] procList = Process.GetProcessesByName(name);
if (procList.Length > 0)
{
procList[0].Kill();
Bolres = true;
}
else
{
Bolres = false;
}
return Bolres;
}
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
You can find stacks of tutorials on line about how to create services.
There is one here[^], or just google for them.
Simon
|
|
|
|
|
|
I have some classes I am writing that represent units of measurement, and I am trying to do this:
each unit (Inch, Foot, Yard) is essentially a decimal, but has different properties, eg. a foot has 12 inches, a yard has 3 "foots" and 36 inches, so on. Is there a way to say "this class is a decimal" in a way similar to inheretence?
I have tried using the same structure of a decimal, including all of the interfaces it inherets, but that was a god awful mess. Any ideas/suggestions?
______________________
Oh Hamburgers!
|
|
|
|
|
I would imagine that creating wrappers around the decimal struct would do the job. I did a similar thing for binary, octal and hexadecimal with an int here[^].
[Edit] I found this interesting so I've tried a little bit of coding - figured I may as well share it with you! Depending on what you're doing with this data, this may help. This (incomplete but working) struct wraps three ints and does some basic stuff. [/Edit]
public struct Imperial
{
public static readonly Imperial Empty = new Imperial();
public Imperial(int inches)
{
m_Yards = 0;
m_Feet = 0;
m_Inches = 0;
if (inches != 0)
{
m_Yards = inches / 36;
int remainder = inches % (m_Yards * 36);
if (remainder != 0)
{
m_Feet = remainder / 12;
if (m_Feet != 0)
m_Inches = remainder % (m_Feet * 12);
else
m_Inches = remainder;
}
}
}
public Imperial(int yards, int feet, int inches)
{
m_Yards = yards;
m_Feet = feet;
m_Inches = inches;
}
public static implicit operator Imperial(int value)
{
return new Imperial(value);
}
public static Imperial operator +(Imperial value1, Imperial value2)
{
return new Imperial(value1.GetTotalInches() + value2.GetTotalInches());
}
private int m_Yards;
private int m_Feet;
private int m_Inches;
public int Yards
{
get { return m_Yards; }
}
public int Feet
{
get { return m_Feet; }
}
public int Inches
{
get { return m_Inches; }
}
public int GetTotalInches()
{
return ((m_Yards * 36) + (m_Feet * 12) + m_Inches);
}
public static Imperial MillimetersToImperial(int millimeters)
{
return new Imperial((int)(millimeters * 0.0393700787));
}
public override string ToString()
{
return string.Format("{0} yards, {1} feet, {2} inches", m_Yards, m_Feet, m_Inches);
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Awesome. The method mentione din the article is the one i went with. I created a class that handles the basics like converting and constructors, then inheret it with the other classes. Works like a charm
______________________
Oh Hamburgers!
|
|
|
|
|
Cool - glad you found it useful. If you haven't already, comment and/or vote on the article!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
If you have a logical way of doing the conversion, you could add implicit conversions to and from a numerical data type. That way you can assign a numerical value to a measurement variable, and use a measurement value where a numerical value is required. (I'm not sure that Decimal is the right choise of numerical data type though. A double might be a better fit.)
However, it looks like you would have to specify the unit for the value to make sense as a measurement?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Your message title is misleading.
You cannot "inherit" a struct .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That was why it was in quotes.
______________________
Oh Hamburgers!
|
|
|
|
|
[EDIT]We have a workaround now, because the workflow would result in other errors [/EDIT]
I should 'simulate' a left-click or set the cursor to the position of the mouse, when right clicking (popup contextmenu) is occuring.
I tried mainly this:
mea = new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta);
OnMouseClick(mea);
but that doesn't work. I also tried to move my cursor position:
Cursor.Position = new Point(e.X, e.Y);
but nothing works. My guess is that the context menu is ahead of me although I should think that OnMouseDown would be before the contextmenu request?
How can I do this?
Many thanks !
modified on Thursday, October 23, 2008 10:03 AM
|
|
|
|
|
hi
use
int index = RichTextBox.GetCharIndexFromPoint(Point pt);
to get the position of the char under the mouse.
use
RichTextBox.SelectionStart = index;
RichTextBox.SelectionLength = 0; // maybe this line is not necessary
to move the cursor inside the textbox.
regards
|
|
|
|
|
i m using Visual studio 2005 with c#.here i am having a problem that i have a RadioButtonList which retrives data from sql datasource. it displays the Items correctly.Now when i try to display the SelectedItems on a label i get an error.kindly help me m stuck..m a student a really new to it.please help..thanx a lot...
DETAILS OF PROBLEM IS AS FOLLOWS:
the error i am getting on browser page is :-
"Server Error in '/Website_dtc' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
"
the RadiobuttonList is databound as follows-
"RadioButtonList1.DataSource = ds.Tables["temp1"];
RadioButtonList1.DataTextField = "buses";
RadioButtonList1.DataValueField = "buses";
RadioButtonList1.DataBind();
"
the RadiobuttonList Item is selected as:-
" protected void Button1_Click(object sender, EventArgs e)
{
lbltemp.Text = RadioButtonList1.SelectedItem.Text;
}
"
Winning isn't everything,its the ONLY thing.
|
|
|
|
|
i am giving the exception....
((System.ComponentModel.ISupportInitialize)(this.performanceCounterMemoryPageRead)).EndInit();
plz...help me out
I am very interested with OOP & its modeling.
|
|
|
|
|
That's the line of code that throws the exception, but what exception are you getting?
|
|
|
|