473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Expose Form Properties and it Controls Properties.

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
9 1640
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ColinWard | last post by:
Hi. I have a form which has as its recordsource an SQL string. The SQL String is as follows: SELECT * from CONTACTS where false. this ensures that there is no data loaded in the form when the...
7
by: Saintor | last post by:
What I do now is I put a value in the tag property, and using the form_current event, I run through all controls properties until the ones with the required tag value are met. Sound OK in theory,...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
1
by: Susan Bricker | last post by:
Greetings. I am trying to position opened forms so that they are cascaded on the screen. I have discovered the movesize action (for the DoCmd) and Move property of a form (for Acc 2002/2003). ...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
1
by: Stefan W via .NET 247 | last post by:
I'm relatively new to C#, (I have to use it, now that I'veinherited someone else's projects). I'm looking for a way toiterate through the controls on a form; if the control is of acertain type, I...
2
by: ljh | last post by:
I am using some 3rd party controls to create my own control. I want to "pass up" many (but not all) of the properties of the 3rd party controls that I am using to make my control, so that the end...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.