Click here to Skip to main content
15,917,808 members
Home / Discussions / C#
   

C#

 
QuestionAccess Controls from another class Pin
tray_gator4-Feb-06 9:07
tray_gator4-Feb-06 9:07 
AnswerRe: Access Controls from another class Pin
kasik4-Feb-06 11:00
kasik4-Feb-06 11:00 
QuestionRe: Access Controls from another class Pin
tray_gator4-Feb-06 22:44
tray_gator4-Feb-06 22:44 
AnswerRe: Access Controls from another class Pin
Colin Angus Mackay4-Feb-06 15:22
Colin Angus Mackay4-Feb-06 15:22 
QuestionRe: Access Controls from another class Pin
tray_gator4-Feb-06 22:51
tray_gator4-Feb-06 22:51 
AnswerRe: Access Controls from another class Pin
mav.northwind4-Feb-06 23:52
mav.northwind4-Feb-06 23:52 
QuestionRe: Access Controls from another class Pin
tray_gator5-Feb-06 0:41
tray_gator5-Feb-06 0:41 
AnswerRe: Access Controls from another class Pin
kasik5-Feb-06 1:28
kasik5-Feb-06 1:28 
In your first post you had a function in your Form1 class like this:
private void callFunctionFromForm()
{
    Class1 cls1 = new Class1(this); // <-- pass the form to cls1 through its constructor
    cls1.test();
}
Now in Class1, you have a variable called _frm1. In Class1's constructor, you do this:
public Class1(Form1 frm1) : this()
{
    _frm1 = frm1;
}
This sets your local variable _frm1 to point at the form that you want altering. Now in your test() method in Class1, you do this:
Form1 frm1= new Form1();
frm1.comboBox1.DataSource = new string[] {"aaa", "bbb"};
The first line of this creates an entirely new form. You then edit this forms combobox. Then the method exits and you loose this form. You need to edit the form that you passed in the constructor, not a new one. If you remove the first line, and then change the second to
_frm1.comboBox1.DataSource = new string[] {"aaa", "bbb"};
it should work. If it doesn't then I must have completely missunderstood your meaning Poke tongue | ;-P

Cheers,
Will H

-- modified at 7:53 Sunday 5th February, 2006
AnswerRe: Access Controls from another class Pin
tray_gator5-Feb-06 2:04
tray_gator5-Feb-06 2:04 
AnswerRe: Access Controls from another class Pin
mav.northwind5-Feb-06 3:07
mav.northwind5-Feb-06 3:07 
GeneralRe: Access Controls from another class Pin
tray_gator5-Feb-06 4:22
tray_gator5-Feb-06 4:22 
GeneralRe: Access Controls from another class Pin
kasik5-Feb-06 4:57
kasik5-Feb-06 4:57 
GeneralRe: Access Controls from another class Pin
tray_gator5-Feb-06 6:04
tray_gator5-Feb-06 6:04 
GeneralRe: Access Controls from another class Pin
Colin Angus Mackay5-Feb-06 10:42
Colin Angus Mackay5-Feb-06 10:42 
GeneralRe: Access Controls from another class Pin
tray_gator5-Feb-06 22:05
tray_gator5-Feb-06 22:05 
Questionjoining the server with my application Pin
moonangel_bio4-Feb-06 7:39
moonangel_bio4-Feb-06 7:39 
AnswerRe: joining the server with my application Pin
Colin Angus Mackay4-Feb-06 15:18
Colin Angus Mackay4-Feb-06 15:18 
General[Message Deleted] Pin
emran8344-Feb-06 19:48
emran8344-Feb-06 19:48 
GeneralRe: joining the server with my application Pin
Colin Angus Mackay4-Feb-06 23:45
Colin Angus Mackay4-Feb-06 23:45 
GeneralRe: joining the server with my application Pin
moonangel_bio5-Feb-06 1:42
moonangel_bio5-Feb-06 1:42 
GeneralRe: joining the server with my application Pin
Colin Angus Mackay5-Feb-06 1:51
Colin Angus Mackay5-Feb-06 1:51 
GeneralRe: joining the server with my application Pin
Dave Kreskowiak5-Feb-06 5:04
mveDave Kreskowiak5-Feb-06 5:04 
GeneralRe: joining the server with my application Pin
emran8345-Feb-06 10:34
emran8345-Feb-06 10:34 
GeneralRe: joining the server with my application Pin
Colin Angus Mackay5-Feb-06 10:46
Colin Angus Mackay5-Feb-06 10:46 
GeneralRe: joining the server with my application Pin
emran8345-Feb-06 11:15
emran8345-Feb-06 11:15 

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.