Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
Questionreuse business methods as DLL in another project?? Pin
Ashraf Nairoukh22-Jul-06 7:17
Ashraf Nairoukh22-Jul-06 7:17 
QuestionI don't understand why I can't access a function from my Form instance from another class in the same namespace Pin
haz1322-Jul-06 3:13
haz1322-Jul-06 3:13 
AnswerRe: I don't understand why I can't access a function from my Form instance from another class in the same namespace Pin
NaNg1524122-Jul-06 3:28
NaNg1524122-Jul-06 3:28 
QuestionRe: I don't understand why I can't access a function from my Form instance from another class in the same namespace Pin
haz1322-Jul-06 4:11
haz1322-Jul-06 4:11 
AnswerRe: I don't understand ... Pin
Ravi Bhavnani22-Jul-06 4:29
professionalRavi Bhavnani22-Jul-06 4:29 
GeneralRe: I don't understand ... Pin
haz1322-Jul-06 5:25
haz1322-Jul-06 5:25 
GeneralRe: I don't understand ... Pin
Ravi Bhavnani22-Jul-06 5:39
professionalRavi Bhavnani22-Jul-06 5:39 
GeneralRe: I don't understand why I can't access a function from my Form instance from another class in the same namespace [modified] Pin
BoneSoft22-Jul-06 5:36
BoneSoft22-Jul-06 5:36 
Wrong. The problem is he's trying to access the non-static method on the Form1 class instead of an instance of Form1.

The class trying to access an instance of Form1 can only get a reference to the instance of Form1 if it creates the form instance, or the form gives the using class an instance of itself.

The following will work, but it's not a very wise design decision to allow processing classes to has instances of your Form. Better to have you working classes just do work with data and return values that your UI can use.

namespace RouletteV1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void btn1_Click(object sender, EventArgs e) {
            NumberAttributes.Load(this, 1);
        }

        public void SetFormData() {
            textBox1.Text = "Hello";
        }
    }

    public static class NumberAttributes {
        public void Load(Form1 form, short Number) {
            NumberProcessing.UpdateNumArray(form);
        }
    }

    public static class NumberProcessing {
        public void UpdateNumArray(Form1 form) {
            form.SetFormData();
        }
    }
}




Try code model generation tools at BoneSoft.com.


-- modified at 11:46 Monday 24th July, 2006

Whoever voted this message down can kiss my hairy white ass, unless they'd like to actually post something to refute it.
QuestionRe: I don't understand why I can't access a function from my Form instance from another class in the same namespace Pin
haz1322-Jul-06 6:12
haz1322-Jul-06 6:12 
AnswerRe: I don't understand why I can't access a function from my Form instance from another class in the same namespace Pin
haz1322-Jul-06 6:33
haz1322-Jul-06 6:33 
Questionworking with datagrids in Windows Forms [modified] Pin
Rocky#22-Jul-06 2:28
Rocky#22-Jul-06 2:28 
AnswerRe: working with datagrids in Windows Forms Pin
Igor Sukhov22-Jul-06 5:43
Igor Sukhov22-Jul-06 5:43 
GeneralRe: working with datagrids in Windows Forms Pin
Rocky#23-Jul-06 9:56
Rocky#23-Jul-06 9:56 
GeneralRe: working with datagrids in Windows Forms Pin
Igor Sukhov23-Jul-06 13:59
Igor Sukhov23-Jul-06 13:59 
GeneralRe: working with datagrids in Windows Forms Pin
Rocky#23-Jul-06 21:14
Rocky#23-Jul-06 21:14 
QuestionGet the value of a field in a row Pin
Glen Harvy22-Jul-06 2:26
Glen Harvy22-Jul-06 2:26 
AnswerRe: Get the value of a field in a row Pin
albCode22-Jul-06 2:34
albCode22-Jul-06 2:34 
GeneralRe: Get the value of a field in a row Pin
Glen Harvy22-Jul-06 3:02
Glen Harvy22-Jul-06 3:02 
GeneralRe: Get the value of a field in a row [modified] Pin
albCode22-Jul-06 3:06
albCode22-Jul-06 3:06 
GeneralRe: Get the value of a field in a row Pin
Glen Harvy22-Jul-06 3:43
Glen Harvy22-Jul-06 3:43 
QuestionConverting string into byte[] Pin
Mursil22-Jul-06 2:08
Mursil22-Jul-06 2:08 
AnswerRe: Converting string into byte[] Pin
Nader Elshehabi22-Jul-06 2:16
Nader Elshehabi22-Jul-06 2:16 
GeneralRe: Converting string into byte[] Pin
Mursil22-Jul-06 2:21
Mursil22-Jul-06 2:21 
GeneralRe: Converting string into byte[] Pin
Nader Elshehabi22-Jul-06 2:31
Nader Elshehabi22-Jul-06 2:31 
GeneralRe: Converting string into byte[] Pin
Mursil22-Jul-06 2:45
Mursil22-Jul-06 2:45 

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.