Click here to Skip to main content
15,906,341 members
Home / Discussions / C#
   

C#

 
GeneralRe: sound in c# Pin
CPallini3-Jan-09 2:58
mveCPallini3-Jan-09 2:58 
QuestionRetrieving data from the last line in a text file Pin
soulg772-Jan-09 7:35
soulg772-Jan-09 7:35 
GeneralRe: Retrieving data from the last line in a text file Pin
Luc Pattyn2-Jan-09 8:04
sitebuilderLuc Pattyn2-Jan-09 8:04 
AnswerRe: Retrieving data from the last line in a text file Pin
#realJSOP2-Jan-09 8:25
professional#realJSOP2-Jan-09 8:25 
Questionpassing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
suni_dotnet2-Jan-09 6:15
suni_dotnet2-Jan-09 6:15 
AnswerRe: passing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
Colin Angus Mackay2-Jan-09 7:07
Colin Angus Mackay2-Jan-09 7:07 
Questionmy senario Pin
suni_dotnet2-Jan-09 8:41
suni_dotnet2-Jan-09 8:41 
AnswerRe: my senario Pin
Colin Angus Mackay2-Jan-09 12:42
Colin Angus Mackay2-Jan-09 12:42 
suni_dotnet wrote:
fields are not working properly.


I don't see any evidence from this code that you have a field at all.

Here is your code re-written:

class MyForm
{ 
  private string resbutton; // This is the field
 
  protected void Button1_Click(object sender, EventArgs e)
  {
    resbutton = "abcMenu";
    // .....
  }
 
  protected void Button2_Click(object sender, EventArgs e)
  {
    resbutton = "defMenu";
    // .....
  }
 
  protected void Button3_Click(object sender, EventArgs e)
  {
    resbutton = "jklMenu";
    // .....
  }
 
  protected void Button4_Click(object sender, EventArgs e)
  {
    switch(resbutton)
    {
      case "abcMenu":
        // Do stuff based on Button1 being pressed
        break;
      case "defMenu":
        // Do stuff based on Button2 being pressed
        break;
      case "jklMenu":
        // Do stuff based on Button3 being pressed
        break;
      default:
        // Do suff based on none of the buttons being pressed
        break;
    }
  }
}


Of course there may be better ways of doing this, but since we don't know what your actual overall goal is we can't say. Christian's suggestion of using delegates has merit also.

I'd also suggest using something other than a string for the field. Creating a specific enum that enumerates each type of button would be good.


AnswerRe: passing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
Christian Graus2-Jan-09 7:25
protectorChristian Graus2-Jan-09 7:25 
GeneralRe: passing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
#realJSOP2-Jan-09 7:33
professional#realJSOP2-Jan-09 7:33 
Questiona question about information retrieval system Pin
farzaneh_10732-Jan-09 6:13
farzaneh_10732-Jan-09 6:13 
AnswerRe: a question about information retrieval system Pin
Christian Graus2-Jan-09 7:26
protectorChristian Graus2-Jan-09 7:26 
QuestionThe problem to make the marker size of Legend bigger with MS chart control Pin
Seraph_summer2-Jan-09 4:34
Seraph_summer2-Jan-09 4:34 
Questioncomparisons between Zedgraph and MS chart control Pin
Seraph_summer2-Jan-09 4:07
Seraph_summer2-Jan-09 4:07 
AnswerRe: comparisons between Zedgraph and MS chart control Pin
#realJSOP2-Jan-09 4:27
professional#realJSOP2-Jan-09 4:27 
GeneralRe: comparisons between Zedgraph and MS chart control Pin
Seraph_summer2-Jan-09 4:33
Seraph_summer2-Jan-09 4:33 
GeneralRe: comparisons between Zedgraph and MS chart control Pin
#realJSOP2-Jan-09 4:42
professional#realJSOP2-Jan-09 4:42 
GeneralRe: comparisons between Zedgraph and MS chart control Pin
Christian Graus2-Jan-09 5:41
protectorChristian Graus2-Jan-09 5:41 
GeneralRe: comparisons between Zedgraph and MS chart control Pin
Dave Kreskowiak2-Jan-09 6:13
mveDave Kreskowiak2-Jan-09 6:13 
QuestionHow to set my app full trust (CAS) ? Pin
hdv2122-Jan-09 3:20
hdv2122-Jan-09 3:20 
AnswerRe: How to set my app full trust (CAS) ? [modified] Pin
#realJSOP2-Jan-09 3:26
professional#realJSOP2-Jan-09 3:26 
GeneralRe: How to set my app full trust (CAS) ? Pin
hdv2122-Jan-09 9:04
hdv2122-Jan-09 9:04 
GeneralRe: How to set my app full trust (CAS) ? Pin
Mark Churchill3-Jan-09 15:55
Mark Churchill3-Jan-09 15:55 
GeneralRe: How to set my app full trust (CAS) ? Pin
hdv2125-Jan-09 5:53
hdv2125-Jan-09 5:53 
QuestionProblem when closing Form containing DataGridView Pin
kbalias2-Jan-09 1:37
kbalias2-Jan-09 1:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.