473,395 Members | 1,462 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,395 software developers and data experts.

updating the main form from a 2nd form

2
Hi there.

this is what I have... listview on mainform named lstViewFrmMain, 1 textbox and a button on frm 2.

My question is, how do I update the listbox when a user clicks button on the 2nd form?
I've tried using on the main form - this,Refresh(), this,Update(), this.Invalidate() etc and its not helping.

Any help will be tremendous.
Feb 7 '08 #1
4 909
Hi there.

this is what I have... listview on mainform named lstViewFrmMain, 1 textbox and a button on frm 2.

My question is, how do I update the listbox when a user clicks button on the 2nd form?
I've tried using on the main form - this,Refresh(), this,Update(), this.Invalidate() etc and its not helping.

Any help will be tremendous.
are you getting errors? is the code not doing as intended? When posting please include this type of information and anything else that might be relevent.

But to make a suggestion on your problem. Is your listview public? if not mak it public or you cannot update it from another form.
Feb 8 '08 #2
Nunu
2
are you getting errors? is the code not doing as intended? When posting please include this type of information and anything else that might be relevent.

But to make a suggestion on your problem. Is your listview public? if not mak it public or you cannot update it from another form.
Hi there .


It is public and there's no errors at all. If u want I can email u my source code
Thank you
Feb 9 '08 #3
Hi there .


It is public and there's no errors at all. If u want I can email u my source code
Thank you
just post what you have on your button here and Myself or someone else can maybe solve your dellema
Feb 11 '08 #4
wimpos
19
Hi there.

this is what I have... listview on mainform named lstViewFrmMain, 1 textbox and a button on frm 2.

My question is, how do I update the listbox when a user clicks button on the 2nd form?
I've tried using on the main form - this,Refresh(), this,Update(), this.Invalidate() etc and its not helping.

Any help will be tremendous.
Hi

you should use events.

In your second form you declare

Expand|Select|Wrap|Line Numbers
  1.  public delegate void MyUpdateEventHandler(string msg);
  2. public event MyUpdateEventHandler MyUpdateEvent;
  3.  
  4. // in the buttonclick method you add
  5. if(MyUpdateEvent != null)
  6. {
  7.     MyUpdateEvent(myTextBox.Text);
  8. }
In your Main form you do

Expand|Select|Wrap|Line Numbers
  1.  MySecondForm f = new MySecondForm();
  2. f.MyUpdateEventHandler += (pressing TAB TAB in visual studio will auto-generate a method)
  3.  
  4. f.Show();
more info on events: http://www.thescripts.com/forum/thread760508.html

In that generated method you must update your mainForm. However you'll have to use delegates and Control.Invoke for threadsafety.

Hope this helps

Regards
W.
Feb 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: aaj | last post by:
Hi all I have a main form looking at a main table, with a subform looking at a detail table, linked by a key. There are many entries in the sub form bound to the single entry on the main form....
5
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have...
5
by: Richard Stanton | last post by:
Hello all My database has a main form linked to table1. It has several subforms on the main form, all linked to table2. Table1 and Table2 are linked by primary/foreign key, no duplicates...
1
by: Joshua Russell | last post by:
Firstly my main method is like this: static void Main(string args) { // New Form Thread FormHandler myFormHandler = new FormHandler(); ThreadStart myThreadStart = new...
11
by: DW | last post by:
I've gotten this question a couple of times in interviews and I don't know what they are looking for: How do you update a control's property, such as a textbox.text property, from a thread, in...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
6
by: DP | last post by:
hi, i need a little help. i have two tables and 2 forms, one with a subform. i have a 'fildID' in one of the subforms, and i have another table, which has the film information, including a...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.