Click here to Skip to main content
15,896,912 members
Home / Discussions / C#
   

C#

 
QuestionImplementation help. Cheers Guys!! Pin
PSMITH821-Aug-09 0:25
PSMITH821-Aug-09 0:25 
QuestionError: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information. Pin
Omar Akhtar Sheikh31-Jul-09 23:58
Omar Akhtar Sheikh31-Jul-09 23:58 
AnswerRe: Error: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information. Pin
Moreno Airoldi1-Aug-09 2:00
Moreno Airoldi1-Aug-09 2:00 
Questiondisplay text in textbox Pin
Abdul Rahman Hamidy31-Jul-09 22:26
Abdul Rahman Hamidy31-Jul-09 22:26 
AnswerRe: display text in textbox Pin
OriginalGriff31-Jul-09 22:44
mveOriginalGriff31-Jul-09 22:44 
GeneralRe: display text in textbox Pin
Abdul Rahman Hamidy31-Jul-09 22:53
Abdul Rahman Hamidy31-Jul-09 22:53 
GeneralRe: display text in textbox Pin
AhsanS31-Jul-09 23:05
AhsanS31-Jul-09 23:05 
GeneralRe: display text in textbox Pin
OriginalGriff31-Jul-09 23:21
mveOriginalGriff31-Jul-09 23:21 
If I understand you correctly, you have a form with a textbox, and a separate class which does some work and is to display text in the textbox?
If yes, then either:

1) the class needs to be given the instance of the form.
or
2) the class needs to signal to the form that data is ready for display.

The first way is pretty trivial, the second is better practice.

Assuming:
myForm formMine = new myForm();
myClass classMine = new myClass();


In the first case, create a field in myClass:
public myForm formDisplayResult;

and assign it after the form and class creation:
myForm formMine = new myForm();
myClass classMine = new myClass();
classMine.formDisplayResult = formMine;

then access the textbox from your class:
formDisplayResult.tbResultsGoHere.Text = "Hello";


In the second case, it is a little more complex:

In myClass:
public partial class myClass
   {
   // Signal file change happened
   public delegate void ChangeHandler(object sender, EventArgs e);
   public event ChangeHandler Changed;

   protected virtual void OnChanged(EventArgs e)
      {
      ChangeHandler ch = Changed;
      if (ch != null)
         {
         ch(this, e);
         }
      }

   private void DoSomethingToChangeData()
      {
      OnChanged(null);
      }
   }

----- The asign to ch is in case the handler changes between null check
----- and exec.
----- (unlikely, but possible)

----- The null check is to ensure there is a handler. If not, better to
----- ignore it gracefully, than to rely on the thrown exception
----- (NullReferenceException)



In myForm:
myClass classMine = new myClass();
public myForm()
    {
    classMine.Change += new myClass.ChangeHandler(Changed);
    }

//
// Fired when the results are available
//
private void Changed(object sender, EventArgs e)
    {
    tbResultsGoHere.Text = classMine.strResults;
    }


It is easy really - you just have to get your head around it!

No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.

This message is made of fully recyclable Zeros and Ones

GeneralRe: display text in textbox Pin
Abdul Rahman Hamidy1-Aug-09 1:38
Abdul Rahman Hamidy1-Aug-09 1:38 
GeneralRe: display text in textbox Pin
Henry Minute1-Aug-09 2:10
Henry Minute1-Aug-09 2:10 
GeneralRe: display text in textbox Pin
OriginalGriff1-Aug-09 4:47
mveOriginalGriff1-Aug-09 4:47 
GeneralRe: display text in textbox Pin
DaveyM691-Aug-09 9:12
professionalDaveyM691-Aug-09 9:12 
GeneralRe: display text in textbox Pin
OriginalGriff1-Aug-09 22:24
mveOriginalGriff1-Aug-09 22:24 
GeneralRe: display text in textbox Pin
Abdul Rahman Hamidy1-Aug-09 18:07
Abdul Rahman Hamidy1-Aug-09 18:07 
GeneralRe: display text in textbox Pin
OriginalGriff1-Aug-09 22:22
mveOriginalGriff1-Aug-09 22:22 
GeneralRe: display text in textbox Pin
Abdul Rahman Hamidy2-Aug-09 1:01
Abdul Rahman Hamidy2-Aug-09 1:01 
GeneralRe: display text in textbox Pin
OriginalGriff2-Aug-09 1:24
mveOriginalGriff2-Aug-09 1:24 
GeneralRe: display text in textbox Pin
Abdul Rahman Hamidy2-Aug-09 17:54
Abdul Rahman Hamidy2-Aug-09 17:54 
QuestionGlobalAppointmentID Pin
248912831-Jul-09 22:12
248912831-Jul-09 22:12 
QuestionHow to caluclate the sum in datagridview Pin
Anjani Poornima31-Jul-09 20:59
Anjani Poornima31-Jul-09 20:59 
AnswerRe: How to caluclate the sum in datagridview Pin
dan!sh 31-Jul-09 21:43
professional dan!sh 31-Jul-09 21:43 
Questioncrystal report in c#.net Pin
Milind Panchal31-Jul-09 20:19
Milind Panchal31-Jul-09 20:19 
AnswerRe: crystal report in c#.net Pin
Abdul Rahman Hamidy31-Jul-09 22:58
Abdul Rahman Hamidy31-Jul-09 22:58 
AnswerRe: crystal report in c#.net Pin
nelsonpaixao1-Aug-09 5:38
nelsonpaixao1-Aug-09 5:38 
Questionobfuscation Pin
devvvy31-Jul-09 20:19
devvvy31-Jul-09 20:19 

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.