Click here to Skip to main content
15,893,622 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is Session ID Unique? Pin
N a v a n e e t h25-Oct-07 0:03
N a v a n e e t h25-Oct-07 0:03 
GeneralRe: Is Session ID Unique? Pin
Guffa25-Oct-07 1:12
Guffa25-Oct-07 1:12 
GeneralRe: Is Session ID Unique? Pin
N a v a n e e t h25-Oct-07 1:23
N a v a n e e t h25-Oct-07 1:23 
AnswerRe: Is Session ID Unique? Pin
Pete O'Hanlon24-Oct-07 22:51
mvePete O'Hanlon24-Oct-07 22:51 
Questionalternative to messagebox.show() method. Pin
pekhaleyogesh24-Oct-07 21:58
pekhaleyogesh24-Oct-07 21:58 
GeneralRe: alternative to messagebox.show() method. Pin
Martin#24-Oct-07 22:14
Martin#24-Oct-07 22:14 
GeneralRe: alternative to messagebox.show() method. Pin
pekhaleyogesh24-Oct-07 22:48
pekhaleyogesh24-Oct-07 22:48 
GeneralRe: alternative to messagebox.show() method. [modified] Pin
Martin#24-Oct-07 23:25
Martin#24-Oct-07 23:25 
Hello,

It's clear that during design time you will not see a control which is not implemented with the designer.

Apart from, that your code doesn't even compile.
Marking a control as static on a Form is just nasty, dirty and bad bad bad!

I think your problems started as you were not able to path the value (string) back to your form.
So you came up with the static solution!

You could path the instance of the form over the constructor of the "clsBatch" class and then call a non static method, which adds the item to the non static ListBox (which was placed over the designer).
class clsBatch
{
    frmMain MainForm = null;
    public clsBatch(frmMain mainForm)
    {
        MainForm = mainForm;
    }
    
    public void fnBatch()
    {
        if(MainForm!=null)
            MainForm.status("Hi");
    }
}

A nicer and more OO solution would be to use delegates, which is very good discriped in this article[^] from Colin!

But, the problem of not seeing your "Hi" will still be the same!

What you can do is:
Make a UserControl and place a Listbox on it.
Set the "Dock" property to "Fill".
Add the the code there and place the usercontrol, over the designer, on the Form.
You can instanciate the "clsBatch" in the constructor and call the method there.
   public class ListBoxControl : System.Windows.Forms.UserControl
   {
       private System.Windows.Forms.ListBox myListBox;
       private System.ComponentModel.Container components = null;

       public ListBoxControl()
       {
           InitializeComponent();

           clsBatch objbatch = new clsBatch(this);
           objbatch.fnBatch();
       }

       public void status(string strMsg)
       {
           myListBox.Items.Add(strMsg);
       }
...

The reason it will work now, is that for the usercontrol it's runtime now!

Hope it helps!








-- modified at 5:31 Thursday 25th October, 2007

All the best,

Martin

GeneralRe: alternative to messagebox.show() method. Pin
pekhaleyogesh24-Oct-07 23:57
pekhaleyogesh24-Oct-07 23:57 
GeneralRe: alternative to messagebox.show() method. Pin
Martin#24-Oct-07 23:59
Martin#24-Oct-07 23:59 
AnswerRe: alternative to messagebox.show() method. Pin
Christian Graus24-Oct-07 22:21
protectorChristian Graus24-Oct-07 22:21 
GeneralRe: alternative to messagebox.show() method. Pin
pekhaleyogesh24-Oct-07 22:49
pekhaleyogesh24-Oct-07 22:49 
AnswerRe: alternative to messagebox.show() method. Pin
Abhijit Jana24-Oct-07 22:31
professionalAbhijit Jana24-Oct-07 22:31 
GeneralRe: alternative to messagebox.show() method. Pin
pekhaleyogesh24-Oct-07 22:50
pekhaleyogesh24-Oct-07 22:50 
QuestionIList use in c# Pin
kanza azhar24-Oct-07 21:40
kanza azhar24-Oct-07 21:40 
AnswerRe: IList use in c# Pin
Martin#24-Oct-07 22:06
Martin#24-Oct-07 22:06 
QuestionAsynchronous Web Service Methods Pin
Neeraj Kr24-Oct-07 21:34
Neeraj Kr24-Oct-07 21:34 
QuestionSEARCH ENGINE Pin
Sandep H S24-Oct-07 20:53
Sandep H S24-Oct-07 20:53 
AnswerRe: SEARCH ENGINE Pin
Christian Graus24-Oct-07 20:57
protectorChristian Graus24-Oct-07 20:57 
GeneralRe: SEARCH ENGINE Pin
Paul Conrad27-Oct-07 12:35
professionalPaul Conrad27-Oct-07 12:35 
AnswerRe: SEARCH ENGINE Pin
N a v a n e e t h24-Oct-07 20:59
N a v a n e e t h24-Oct-07 20:59 
GeneralRe: SEARCH ENGINE Pin
Christian Graus24-Oct-07 21:06
protectorChristian Graus24-Oct-07 21:06 
GeneralRe: SEARCH ENGINE Pin
N a v a n e e t h24-Oct-07 21:12
N a v a n e e t h24-Oct-07 21:12 
AnswerRe: SEARCH ENGINE Pin
_tasleem24-Oct-07 21:31
_tasleem24-Oct-07 21:31 
AnswerRe: SEARCH ENGINE Pin
Nouman Bhatti24-Oct-07 23:28
Nouman Bhatti24-Oct-07 23:28 

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.