Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C# Multiple forms not interacting with each other :/

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Tue Sep 22, 2009 10:45 pm    Post subject: C# Multiple forms not interacting with each other :/ Reply with quote

k I have this 2 forms
reminderform.cs and List.cs

I have this button in the reminderform.cs

Code:
private void Add_Click(object sender, EventArgs e){
            List form2 = new List();
            form2.ShowDialog();
            string remindme = this.Reminder.Text;
            form2.listBoxList.Items.Add(remindme) ;
            this.Reminder.Text = "";


           
        }


which does everything but add the new entry to the list in the other form

whats wrong ? X_x?

___________

forget it, I just discovered it was all about changing the button protection from private to public
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Sep 22, 2009 11:26 pm    Post subject: Reply with quote

This is a terrible way to architect your program, perhaps you should consider designing your class structure.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Sep 22, 2009 11:38 pm    Post subject: Reply with quote

Events are the best way to handle this if I remember right
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Sep 22, 2009 11:41 pm    Post subject: Reply with quote

Here is a hint: GUIs are for displaying information, not storing information.
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Wed Sep 23, 2009 12:06 am    Post subject: Reply with quote

This is how I do it:
Code:

public partial class List : Form
{
public void UpdateList (List<string> items)
{
foreach(string item in items)
      listBoxList.Add(item);
}
}
public partial class form1 : Form
{
List form2 = new List();
List listToShow = new List<string>();
private void Add_Click(object sender, EventArgs e){
           if(form2.IsDisposed)
                  form2.Show();
            listToShow.Add(this.reminder.Text);
            form2.UpdateList(listToShow);
            this.Reminder.Text = "";
        } 
}

Edit:Fixed an error in the code.

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Wed Sep 23, 2009 8:03 am    Post subject: Reply with quote

thanks guys but I got it to work yesterday xP I wrote to forget about this post but meh, thanks anyways

this is my current code:

Code:
namespace WindowsFormsApplication1
{
    public partial class ReminderForm : Form
    {
        public ReminderForm()
        {
            InitializeComponent();
           
        }
        List form2 = new List();

        private void Add_Click(object sender, EventArgs e){
         
            form2.listBoxList.Items.Add(this.Date.Value.Day + "/" + this.Date.Value.Month + " at " + this.Time.Text +"    "+ this.Reminder.Text);
            this.Reminder.Text = "";
           
        }

        private void Showlist_Click(object sender, EventArgs e)
        {
           
            form2.ShowDialog();

        }
}
}
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites