0

on my main form:

public string updateButtonText
{
   get { return btnInbox.Text; }
   set { btnInbox.Text = value; }
}

on my usercontrol:

public void refreshInbox()
{
   try
   {
       mailboxLogic.constructInbox(lstViewInbox, StudentsData.studentUsername);
       frmMailbox.updateButtonText = "Inbox" + "(" + MailboxLogic.emailcounter + ")";
   }
   catch (Exception ex)
   {
       MessageBox.Show("1"+ex.Message);
   }
}

i am trying to call the updateButtonText method everytime i update my listview.can someone help please?

Omar
  • 16,329
  • 10
  • 48
  • 66
user2092583
  • 1
  • 2
  • 4
  • 1
    What's the problem here? – Omar Feb 20 '13 at 18:42
  • 1
    `updateButtonText` property should not contain a `get` method since its just for updating. or change it to a method. or just rename it to `ButtonText` if you also want to get the button text. – Abdusalam Ben Haj Feb 20 '13 at 18:49
  • yes get is not required. my issue is that frmMailbox.updateButtonText is not callable – user2092583 Feb 20 '13 at 18:57
  • what is frmMailBox. Where is it declared? is the grid a parent or a child of it, or is it completely un-related to it? – Nevyn Feb 20 '13 at 19:41
  • frmMailbox is the parent form that contains the user control. frmMailbox contains the method to update the text on the button and the usercontrol contains the method that will perform an update on itself as well as calling the method from frmMailbox – user2092583 Feb 20 '13 at 19:45

1 Answers1

0

If you just want to know how to update a textbox when a listview item is selected, then you want to look at the ItemSelectionChanged event. Otherwise, have a look at any of the other events in the listview class.

If you do not understand events, then I suggest this SO question

Community
  • 1
  • 1
Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
  • i already have a method(constructInbox(-,-) that updates my listview whenever a new message arrives. everytime i need to call constructInbox, i also want to call updateButtonText() but the latter is not reachable since it is from the parent form. btw thanks for the link. – user2092583 Feb 20 '13 at 19:05
  • Pass the parent form into the child. Make the parent form static and just reference it. Or use the `ParentForm` property http://msdn.microsoft.com/en-US/library/system.windows.forms.containercontrol.parentform(v=vs.100).aspx You can cast to your specific form type and access the property that way – Justin Pihony Feb 20 '13 at 19:10