Click here to Skip to main content
15,924,318 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# how I can sniff a process? Pin
Richard MacCutchan10-Jan-12 2:36
mveRichard MacCutchan10-Jan-12 2:36 
GeneralRe: C# how I can sniff a process? Pin
terrinfo10-Jan-12 3:06
terrinfo10-Jan-12 3:06 
GeneralRe: C# how I can sniff a process? Pin
Richard MacCutchan10-Jan-12 3:26
mveRichard MacCutchan10-Jan-12 3:26 
GeneralRe: C# how I can sniff a process? Pin
terrinfo10-Jan-12 3:32
terrinfo10-Jan-12 3:32 
GeneralRe: C# how I can sniff a process? Pin
Richard MacCutchan10-Jan-12 3:45
mveRichard MacCutchan10-Jan-12 3:45 
GeneralRe: C# how I can sniff a process? Pin
terrinfo10-Jan-12 3:48
terrinfo10-Jan-12 3:48 
GeneralRe: C# how I can sniff a process? Pin
Richard MacCutchan10-Jan-12 4:06
mveRichard MacCutchan10-Jan-12 4:06 
QuestionC# -Oracle- Access Pin
bigphish9-Jan-12 8:33
bigphish9-Jan-12 8:33 
AnswerRe: C# -Oracle- Access Pin
RexGrammer9-Jan-12 8:45
RexGrammer9-Jan-12 8:45 
GeneralRe: C# -Oracle- Access Pin
bigphish9-Jan-12 19:04
bigphish9-Jan-12 19:04 
GeneralRe: C# -Oracle- Access Pin
Mycroft Holmes9-Jan-12 20:25
professionalMycroft Holmes9-Jan-12 20:25 
AnswerRe: C# -Oracle- Access Pin
jschell11-Jan-12 9:36
jschell11-Jan-12 9:36 
QuestionWinforms Update form label from a class library Pin
Member 43365949-Jan-12 4:53
Member 43365949-Jan-12 4:53 
AnswerRe: Winforms Update form label from a class library Pin
BobJanova9-Jan-12 5:05
BobJanova9-Jan-12 5:05 
GeneralRe: Winforms Update form label from a class library Pin
Member 43365949-Jan-12 5:17
Member 43365949-Jan-12 5:17 
GeneralRe: Winforms Update form label from a class library Pin
BobJanova9-Jan-12 6:46
BobJanova9-Jan-12 6:46 
AnswerRe: Winforms Update form label from a class library Pin
RexGrammer9-Jan-12 8:11
RexGrammer9-Jan-12 8:11 
AnswerRe: Winforms Update form label from a class library Pin
Luc Pattyn9-Jan-12 8:15
sitebuilderLuc Pattyn9-Jan-12 8:15 
GeneralRe: Winforms Update form label from a class library Pin
DaveyM699-Jan-12 8:43
professionalDaveyM699-Jan-12 8:43 
I agree with Luc - this is not a good method. The class library should not have or need any knowlege of any UI control. The normal way would be to get the text from the BusinessLayer vie a getter or string GetXXX() method and deal with updating the text in the UI layer.

Luc's suggestion of passing a delegate is an alternative aproach which is also valid and allows the calling of the update code from the BusinessLayer without it needing information about the control - the actual update is still done in the UI layer. Delegates often confuse people but they're pretty simple so here is an example. I prefer other options but here is how it is done:

C#
// CommonObjects class library

namespace CommonObjects
{
    public delegate void UpdateText(string text);
}

C#
// BusinessLayer class library, references CommonObjects

using CommonObjects;

namespace BusinessLayer
{
    public class Strings
    {
        public static void RequestUpdateText(UpdateText updateText)
        {
            updateText.Invoke("New Text");
        }
    }
}

C#
// Presentation layer - a winforms app here with a TextBox (textBox) on the main form (FormMain instance),
// references CommonObjects

using System.Windows.Forms;
using CommonObjects;

public partial class FormMain : Form
{
    public FormMain()
    {
        InitializeComponent();
        RequestUpdateFromClassLibrary();
    }

    private void RequestUpdateFromClassLibrary()
    {
        BusinessLayer.Strings.RequestUpdateText(new UpdateText(UpdateTextBox));
    }
    private void UpdateTextBox(string text)
    {
        textBox.Text = text;
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



AnswerRe: Winforms Update form label from a class library Pin
BillWoodruff10-Jan-12 6:17
professionalBillWoodruff10-Jan-12 6:17 
QuestionHow to access the control of a form from diffrent form? Pin
Paramu19739-Jan-12 4:08
Paramu19739-Jan-12 4:08 
AnswerRe: How to access the control of a form from diffrent form? Pin
Ravi Bhavnani9-Jan-12 4:15
professionalRavi Bhavnani9-Jan-12 4:15 
AnswerRe: How to access the control of a form from diffrent form? Pin
RexGrammer9-Jan-12 8:09
RexGrammer9-Jan-12 8:09 
AnswerRe: How to access the control of a form from diffrent form? Pin
DaveyM699-Jan-12 9:07
professionalDaveyM699-Jan-12 9:07 
AnswerRe: How to access the control of a form from diffrent form? Pin
BillWoodruff10-Jan-12 6:55
professionalBillWoodruff10-Jan-12 6:55 

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.