By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,272 Members | 1,420 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,272 IT Pros & Developers. It's quick & easy.

Expose Form Properties and it Controls Properties.

P: n/a
Hi,

How do i expose all my forms and it controls to other form in the project?
I want to be able to add a form and some control on it, this then be
available to all other forms.

form1 click event:
'this allow me to change the textbox on form2 from form1
Form2.text=""
'this allow me to add item to form2 from form1
Form2.listview.item.add("")
end form1 click event:

Dimsion
Visual Studio 2005/VB

====Sorry to double post this, but maybe where i have posted this quesiton
was not the right place the first time.===
Jun 15 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hello:

Declare a instance of form 2 in form1 and use that instance to refer to
form2's controls.
Like:
Dim instfrm2 as New form2
instfrm2.text = ""
instfrm2.listview.item.add("")

You might even declare a public variable for form2 and access it within
form1.

Hope this helps

Jun 15 '06 #2

P: n/a
I believe all forms are public by default and all controls are Friends
by default unless you change the modifiers property of that control to
something else. Friends modifier means, other classes/forms within the
same project/assembly are permitted to change the properties and adding
items to the control. Let's go back to your example:

you have form1 that has a click capture a click event
Form2 has a textbox and a listview controls
Now, when the click event is fired:
Form2.textbox.text = "Whatever" and Form2.listview.item.add("Whatever")
are excuted and they shouldn't cause any problems.

I am assuming that both forms are running on the same thread. If each
as its own thread, you need to use delegates or p/invoke. Somebody
correct me if I am wrong.

Ahmed
Dimsion wrote:
Hi,

How do i expose all my forms and it controls to other form in the project?
I want to be able to add a form and some control on it, this then be
available to all other forms.

form1 click event:
'this allow me to change the textbox on form2 from form1
Form2.text=""
'this allow me to add item to form2 from form1
Form2.listview.item.add("")
end form1 click event:

Dimsion
Visual Studio 2005/VB

====Sorry to double post this, but maybe where i have posted this quesiton
was not the right place the first time.===


Jun 15 '06 #3

P: n/a
Ahmed,

I have two project that i work on, the old one can communicate between forms
and controls. If i added a new form and control on it to that project it can
continue to allow me to access the form and controls. However if i start a
new proect, it will not work the same way.

I have try to declare as IdelBrain mention in the other thread, but it only
allow me access to the form and not it controls.

Thanks,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I believe all forms are public by default and all controls are Friends
by default unless you change the modifiers property of that control to
something else. Friends modifier means, other classes/forms within the
same project/assembly are permitted to change the properties and adding
items to the control. Let's go back to your example:

you have form1 that has a click capture a click event
Form2 has a textbox and a listview controls
Now, when the click event is fired:
Form2.textbox.text = "Whatever" and Form2.listview.item.add("Whatever")
are excuted and they shouldn't cause any problems.

I am assuming that both forms are running on the same thread. If each
as its own thread, you need to use delegates or p/invoke. Somebody
correct me if I am wrong.

Ahmed
Dimsion wrote:
Hi,

How do i expose all my forms and it controls to other form in the
project?
I want to be able to add a form and some control on it, this then be
available to all other forms.

form1 click event:
'this allow me to change the textbox on form2 from form1
Form2.text=""
'this allow me to add item to form2 from form1
Form2.listview.item.add("")
end form1 click event:

Dimsion
Visual Studio 2005/VB

====Sorry to double post this, but maybe where i have posted this
quesiton
was not the right place the first time.===

Jun 15 '06 #4

P: n/a
It didn't allow you to access them because their modifier is set to
Friends which is the default value. If you select and of the controls
(listview, buttons), in the properties window there is an entry called
modifers. You need to set that to public. But, that means anybody who
knows .NET can include your excutable in their project and have fun
with it.

Dimsion wrote:
Ahmed,

I have two project that i work on, the old one can communicate between forms
and controls. If i added a new form and control on it to that project it can
continue to allow me to access the form and controls. However if i start a
new proect, it will not work the same way.

I have try to declare as IdelBrain mention in the other thread, but it only
allow me access to the form and not it controls.

Thanks,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I believe all forms are public by default and all controls are Friends
by default unless you change the modifiers property of that control to
something else. Friends modifier means, other classes/forms within the
same project/assembly are permitted to change the properties and adding
items to the control. Let's go back to your example:

you have form1 that has a click capture a click event
Form2 has a textbox and a listview controls
Now, when the click event is fired:
Form2.textbox.text = "Whatever" and Form2.listview.item.add("Whatever")
are excuted and they shouldn't cause any problems.

I am assuming that both forms are running on the same thread. If each
as its own thread, you need to use delegates or p/invoke. Somebody
correct me if I am wrong.

Ahmed
Dimsion wrote:
Hi,

How do i expose all my forms and it controls to other form in the
project?
I want to be able to add a form and some control on it, this then be
available to all other forms.

form1 click event:
'this allow me to change the textbox on form2 from form1
Form2.text=""
'this allow me to add item to form2 from form1
Form2.listview.item.add("")
end form1 click event:

Dimsion
Visual Studio 2005/VB

====Sorry to double post this, but maybe where i have posted this
quesiton
was not the right place the first time.===


Jun 15 '06 #5

P: n/a
Thanks Ahmed,

The project default was private, that's why i can't get it to work.
I have change it to friend and everything work fine. I think friend would
only allow the program access the properties and not everyone else(i
think..).

Thanks you sooo much!!

Dimsion.

"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
It didn't allow you to access them because their modifier is set to
Friends which is the default value. If you select and of the controls
(listview, buttons), in the properties window there is an entry called
modifers. You need to set that to public. But, that means anybody who
knows .NET can include your excutable in their project and have fun
with it.

Dimsion wrote:
Ahmed,

I have two project that i work on, the old one can communicate between
forms
and controls. If i added a new form and control on it to that project it
can
continue to allow me to access the form and controls. However if i start
a
new proect, it will not work the same way.

I have try to declare as IdelBrain mention in the other thread, but it
only
allow me access to the form and not it controls.

Thanks,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
>I believe all forms are public by default and all controls are Friends
> by default unless you change the modifiers property of that control to
> something else. Friends modifier means, other classes/forms within the
> same project/assembly are permitted to change the properties and adding
> items to the control. Let's go back to your example:
>
> you have form1 that has a click capture a click event
> Form2 has a textbox and a listview controls
> Now, when the click event is fired:
> Form2.textbox.text = "Whatever" and Form2.listview.item.add("Whatever")
> are excuted and they shouldn't cause any problems.
>
> I am assuming that both forms are running on the same thread. If each
> as its own thread, you need to use delegates or p/invoke. Somebody
> correct me if I am wrong.
>
> Ahmed
>
>
> Dimsion wrote:
>> Hi,
>>
>> How do i expose all my forms and it controls to other form in the
>> project?
>> I want to be able to add a form and some control on it, this then be
>> available to all other forms.
>>
>> form1 click event:
>> 'this allow me to change the textbox on form2 from form1
>> Form2.text=""
>> 'this allow me to add item to form2 from form1
>> Form2.listview.item.add("")
>> end form1 click event:
>>
>> Dimsion
>> Visual Studio 2005/VB
>>
>> ====Sorry to double post this, but maybe where i have posted this
>> quesiton
>> was not the right place the first time.===
>

Jun 15 '06 #6

P: n/a
Ahmed,

Do you know how to set the default to be friend instead of private?

Thanks,
Dimsion

"Dimsion" <di*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Thanks Ahmed,

The project default was private, that's why i can't get it to work.
I have change it to friend and everything work fine. I think friend would
only allow the program access the properties and not everyone else(i
think..).

Thanks you sooo much!!

Dimsion.

"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
It didn't allow you to access them because their modifier is set to
Friends which is the default value. If you select and of the controls
(listview, buttons), in the properties window there is an entry called
modifers. You need to set that to public. But, that means anybody who
knows .NET can include your excutable in their project and have fun
with it.

Dimsion wrote:
Ahmed,

I have two project that i work on, the old one can communicate between
forms
and controls. If i added a new form and control on it to that project it
can
continue to allow me to access the form and controls. However if i start
a
new proect, it will not work the same way.

I have try to declare as IdelBrain mention in the other thread, but it
only
allow me access to the form and not it controls.

Thanks,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
>I believe all forms are public by default and all controls are Friends
> by default unless you change the modifiers property of that control to
> something else. Friends modifier means, other classes/forms within the
> same project/assembly are permitted to change the properties and
> adding
> items to the control. Let's go back to your example:
>
> you have form1 that has a click capture a click event
> Form2 has a textbox and a listview controls
> Now, when the click event is fired:
> Form2.textbox.text = "Whatever" and
> Form2.listview.item.add("Whatever")
> are excuted and they shouldn't cause any problems.
>
> I am assuming that both forms are running on the same thread. If each
> as its own thread, you need to use delegates or p/invoke. Somebody
> correct me if I am wrong.
>
> Ahmed
>
>
> Dimsion wrote:
>> Hi,
>>
>> How do i expose all my forms and it controls to other form in the
>> project?
>> I want to be able to add a form and some control on it, this then be
>> available to all other forms.
>>
>> form1 click event:
>> 'this allow me to change the textbox on form2 from form1
>> Form2.text=""
>> 'this allow me to add item to form2 from form1
>> Form2.listview.item.add("")
>> end form1 click event:
>>
>> Dimsion
>> Visual Studio 2005/VB
>>
>> ====Sorry to double post this, but maybe where i have posted this
>> quesiton
>> was not the right place the first time.===
>


Jun 16 '06 #7

P: n/a
Hi Dimsion,

The set the default of what?

Let me know.
Ahmed
Dimsion wrote:
Ahmed,

Do you know how to set the default to be friend instead of private?

Thanks,
Dimsion

"Dimsion" <di*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Thanks Ahmed,

The project default was private, that's why i can't get it to work.
I have change it to friend and everything work fine. I think friend would
only allow the program access the properties and not everyone else(i
think..).

Thanks you sooo much!!

Dimsion.

"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
It didn't allow you to access them because their modifier is set to
Friends which is the default value. If you select and of the controls
(listview, buttons), in the properties window there is an entry called
modifers. You need to set that to public. But, that means anybody who
knows .NET can include your excutable in their project and have fun
with it.

Dimsion wrote:
Ahmed,

I have two project that i work on, the old one can communicate between
forms
and controls. If i added a new form and control on it to that project it
can
continue to allow me to access the form and controls. However if i start
a
new proect, it will not work the same way.

I have try to declare as IdelBrain mention in the other thread, but it
only
allow me access to the form and not it controls.

Thanks,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
>I believe all forms are public by default and all controls are Friends
> by default unless you change the modifiers property of that control to
> something else. Friends modifier means, other classes/forms within the
> same project/assembly are permitted to change the properties and
> adding
> items to the control. Let's go back to your example:
>
> you have form1 that has a click capture a click event
> Form2 has a textbox and a listview controls
> Now, when the click event is fired:
> Form2.textbox.text = "Whatever" and
> Form2.listview.item.add("Whatever")
> are excuted and they shouldn't cause any problems.
>
> I am assuming that both forms are running on the same thread. If each
> as its own thread, you need to use delegates or p/invoke. Somebody
> correct me if I am wrong.
>
> Ahmed
>
>
> Dimsion wrote:
>> Hi,
>>
>> How do i expose all my forms and it controls to other form in the
>> project?
>> I want to be able to add a form and some control on it, this then be
>> available to all other forms.
>>
>> form1 click event:
>> 'this allow me to change the textbox on form2 from form1
>> Form2.text=""
>> 'this allow me to add item to form2 from form1
>> Form2.listview.item.add("")
>> end form1 click event:
>>
>> Dimsion
>> Visual Studio 2005/VB
>>
>> ====Sorry to double post this, but maybe where i have posted this
>> quesiton
>> was not the right place the first time.===
>



Jun 16 '06 #8

P: n/a
Sorry about that,
I meant to say do you know how to set the modifier default to friend,
currently every project i started have the modifier set to private.

Thanks again,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Dimsion,

The set the default of what?

Let me know.
Ahmed
Dimsion wrote:
Ahmed,

Do you know how to set the default to be friend instead of private?

Thanks,
Dimsion

"Dimsion" <di*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
> Thanks Ahmed,
>
> The project default was private, that's why i can't get it to work.
> I have change it to friend and everything work fine. I think friend
> would
> only allow the program access the properties and not everyone else(i
> think..).
>
> Thanks you sooo much!!
>
> Dimsion.
>
> "Ahmed" <ah*******@gmail.com> wrote in message
> news:11**********************@g10g2000cwb.googlegr oups.com...
>> It didn't allow you to access them because their modifier is set to
>> Friends which is the default value. If you select and of the controls
>> (listview, buttons), in the properties window there is an entry called
>> modifers. You need to set that to public. But, that means anybody who
>> knows .NET can include your excutable in their project and have fun
>> with it.
>>
>> Dimsion wrote:
>>> Ahmed,
>>>
>>> I have two project that i work on, the old one can communicate
>>> between
>>> forms
>>> and controls. If i added a new form and control on it to that project
>>> it
>>> can
>>> continue to allow me to access the form and controls. However if i
>>> start
>>> a
>>> new proect, it will not work the same way.
>>>
>>> I have try to declare as IdelBrain mention in the other thread, but
>>> it
>>> only
>>> allow me access to the form and not it controls.
>>>
>>> Thanks,
>>> Dimsion
>>>
>>>
>>> "Ahmed" <ah*******@gmail.com> wrote in message
>>> news:11**********************@g10g2000cwb.googlegr oups.com...
>>> >I believe all forms are public by default and all controls are
>>> >Friends
>>> > by default unless you change the modifiers property of that control
>>> > to
>>> > something else. Friends modifier means, other classes/forms within
>>> > the
>>> > same project/assembly are permitted to change the properties and
>>> > adding
>>> > items to the control. Let's go back to your example:
>>> >
>>> > you have form1 that has a click capture a click event
>>> > Form2 has a textbox and a listview controls
>>> > Now, when the click event is fired:
>>> > Form2.textbox.text = "Whatever" and
>>> > Form2.listview.item.add("Whatever")
>>> > are excuted and they shouldn't cause any problems.
>>> >
>>> > I am assuming that both forms are running on the same thread. If
>>> > each
>>> > as its own thread, you need to use delegates or p/invoke. Somebody
>>> > correct me if I am wrong.
>>> >
>>> > Ahmed
>>> >
>>> >
>>> > Dimsion wrote:
>>> >> Hi,
>>> >>
>>> >> How do i expose all my forms and it controls to other form in the
>>> >> project?
>>> >> I want to be able to add a form and some control on it, this then
>>> >> be
>>> >> available to all other forms.
>>> >>
>>> >> form1 click event:
>>> >> 'this allow me to change the textbox on form2 from form1
>>> >> Form2.text=""
>>> >> 'this allow me to add item to form2 from form1
>>> >> Form2.listview.item.add("")
>>> >> end form1 click event:
>>> >>
>>> >> Dimsion
>>> >> Visual Studio 2005/VB
>>> >>
>>> >> ====Sorry to double post this, but maybe where i have posted this
>>> >> quesiton
>>> >> was not the right place the first time.===
>>> >
>>
>
>

Jun 17 '06 #9

P: n/a
But I never saw a modifer for a project. Usually the modifer for the
controls on the form. Just select all controls and set the modifer to
friend or public.

Dimsion wrote:
Sorry about that,
I meant to say do you know how to set the modifier default to friend,
currently every project i started have the modifier set to private.

Thanks again,
Dimsion
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Dimsion,

The set the default of what?

Let me know.
Ahmed
Dimsion wrote:
Ahmed,

Do you know how to set the default to be friend instead of private?

Thanks,
Dimsion

"Dimsion" <di*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
> Thanks Ahmed,
>
> The project default was private, that's why i can't get it to work.
> I have change it to friend and everything work fine. I think friend
> would
> only allow the program access the properties and not everyone else(i
> think..).
>
> Thanks you sooo much!!
>
> Dimsion.
>
> "Ahmed" <ah*******@gmail.com> wrote in message
> news:11**********************@g10g2000cwb.googlegr oups.com...
>> It didn't allow you to access them because their modifier is set to
>> Friends which is the default value. If you select and of the controls
>> (listview, buttons), in the properties window there is an entry called
>> modifers. You need to set that to public. But, that means anybody who
>> knows .NET can include your excutable in their project and have fun
>> with it.
>>
>> Dimsion wrote:
>>> Ahmed,
>>>
>>> I have two project that i work on, the old one can communicate
>>> between
>>> forms
>>> and controls. If i added a new form and control on it to that project
>>> it
>>> can
>>> continue to allow me to access the form and controls. However if i
>>> start
>>> a
>>> new proect, it will not work the same way.
>>>
>>> I have try to declare as IdelBrain mention in the other thread, but
>>> it
>>> only
>>> allow me access to the form and not it controls.
>>>
>>> Thanks,
>>> Dimsion
>>>
>>>
>>> "Ahmed" <ah*******@gmail.com> wrote in message
>>> news:11**********************@g10g2000cwb.googlegr oups.com...
>>> >I believe all forms are public by default and all controls are
>>> >Friends
>>> > by default unless you change the modifiers property of that control
>>> > to
>>> > something else. Friends modifier means, other classes/forms within
>>> > the
>>> > same project/assembly are permitted to change the properties and
>>> > adding
>>> > items to the control. Let's go back to your example:
>>> >
>>> > you have form1 that has a click capture a click event
>>> > Form2 has a textbox and a listview controls
>>> > Now, when the click event is fired:
>>> > Form2.textbox.text = "Whatever" and
>>> > Form2.listview.item.add("Whatever")
>>> > are excuted and they shouldn't cause any problems.
>>> >
>>> > I am assuming that both forms are running on the same thread. If
>>> > each
>>> > as its own thread, you need to use delegates or p/invoke. Somebody
>>> > correct me if I am wrong.
>>> >
>>> > Ahmed
>>> >
>>> >
>>> > Dimsion wrote:
>>> >> Hi,
>>> >>
>>> >> How do i expose all my forms and it controls to other form in the
>>> >> project?
>>> >> I want to be able to add a form and some control on it, this then
>>> >> be
>>> >> available to all other forms.
>>> >>
>>> >> form1 click event:
>>> >> 'this allow me to change the textbox on form2 from form1
>>> >> Form2.text=""
>>> >> 'this allow me to add item to form2 from form1
>>> >> Form2.listview.item.add("")
>>> >> end form1 click event:
>>> >>
>>> >> Dimsion
>>> >> Visual Studio 2005/VB
>>> >>
>>> >> ====Sorry to double post this, but maybe where i have posted this
>>> >> quesiton
>>> >> was not the right place the first time.===
>>> >
>>
>
>


Jun 17 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.