Click here to Skip to main content
15,919,245 members
Home / Discussions / C#
   

C#

 
GeneralRe: DateTime of 24 hours former ? Pin
Ennis Ray Lynch, Jr.27-Sep-09 9:34
Ennis Ray Lynch, Jr.27-Sep-09 9:34 
GeneralRe: DateTime of 24 hours former ? Pin
Richard MacCutchan27-Sep-09 12:31
mveRichard MacCutchan27-Sep-09 12:31 
GeneralRe: DateTime of 24 hours former ? Pin
Ennis Ray Lynch, Jr.27-Sep-09 14:05
Ennis Ray Lynch, Jr.27-Sep-09 14:05 
GeneralRe: DateTime of 24 hours former ? Pin
Richard MacCutchan27-Sep-09 21:35
mveRichard MacCutchan27-Sep-09 21:35 
GeneralRe: DateTime of 24 hours former ? Pin
dan!sh 26-Sep-09 8:04
professional dan!sh 26-Sep-09 8:04 
GeneralRe: DateTime of 24 hours former ? Pin
Luc Pattyn26-Sep-09 9:58
sitebuilderLuc Pattyn26-Sep-09 9:58 
QuestionBitmaps Pin
terradtc26-Sep-09 5:27
terradtc26-Sep-09 5:27 
AnswerRe: Bitmaps Pin
Luc Pattyn26-Sep-09 6:34
sitebuilderLuc Pattyn26-Sep-09 6:34 
AnswerRe: Bitmaps Pin
Alan Balkany28-Sep-09 4:53
Alan Balkany28-Sep-09 4:53 
QuestionCapture stream on in file 'PCL' Pin
abbd26-Sep-09 3:56
abbd26-Sep-09 3:56 
Questionaccessing god damn controls on other forms Pin
teknolog12326-Sep-09 1:47
teknolog12326-Sep-09 1:47 
AnswerRe: accessing god damn controls on other forms Pin
harold aptroot26-Sep-09 1:55
harold aptroot26-Sep-09 1:55 
GeneralRe: accessing god damn controls on other forms Pin
teknolog12326-Sep-09 2:01
teknolog12326-Sep-09 2:01 
GeneralRe: accessing god damn controls on other forms Pin
harold aptroot26-Sep-09 2:19
harold aptroot26-Sep-09 2:19 
AnswerRe: accessing god damn controls on other forms Pin
OriginalGriff26-Sep-09 2:10
mveOriginalGriff26-Sep-09 2:10 
GeneralRe: accessing god damn controls on other forms Pin
teknolog12326-Sep-09 2:20
teknolog12326-Sep-09 2:20 
GeneralRe: accessing god damn controls on other forms Pin
OriginalGriff26-Sep-09 2:23
mveOriginalGriff26-Sep-09 2:23 
AnswerRe: accessing god damn controls on other forms Pin
Alan N26-Sep-09 2:25
Alan N26-Sep-09 2:25 
GeneralRe: accessing god damn controls on other forms Pin
teknolog12326-Sep-09 2:41
teknolog12326-Sep-09 2:41 
GeneralRe: accessing god damn controls on other forms Pin
Alan N26-Sep-09 3:48
Alan N26-Sep-09 3:48 
Ok,
I'm still guessing then. The custom control, masaCubuk, is a child of MainForm and I assume that btn1.Text on the visible instance of MainForm never changes.

If that is the issue then the reason the code does not work lies in these lines:
private void button1_Click(object sender, EventArgs e)
{
  //accessing with this
  MainForm frm = new MainForm();
  frm.buttontext="sample";
} 


Here you intend to communicate with the existing MainForm but have created a new instance. What would be required to get this code fragment to work is a reference to the actual MainForm, i.e. the parent of masaCubuk. You could pass the reference as an argument to masaCubuk's constructor but doing so would introduce the tight coupling that you wish to avoid.

The accepted "loose coupling" technique is to have the main form access the custom control by subscribing to events exposed by the control.

MSDN's How To topic[^]

If you have never written an event this will seem like a lot of work but the code pattern is so standard that once learnt it is easily remembered.

Alan.
AnswerRe: accessing god damn controls on other forms Pin
DaveyM6926-Sep-09 6:51
professionalDaveyM6926-Sep-09 6:51 
GeneralRe: accessing god damn controls on other forms Pin
teknolog12326-Sep-09 9:55
teknolog12326-Sep-09 9:55 
GeneralRe: accessing god damn controls on other forms Pin
DaveyM6926-Sep-09 11:09
professionalDaveyM6926-Sep-09 11:09 
GeneralRe: accessing god damn controls on other forms Pin
teknolog12326-Sep-09 12:54
teknolog12326-Sep-09 12:54 
GeneralC# Final project Pin
Saba Minhas26-Sep-09 1:19
Saba Minhas26-Sep-09 1: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.