Refresh textbox/combobox/datagridview when multiple tabs selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naseemsadak
    New Member
    • Oct 2008
    • 5

    #1

    Refresh textbox/combobox/datagridview when multiple tabs selected

    Hi,

    I'm developing a program in c# 2005 and would like to know if it is possible to refresh a tab page's controls(e.g textboxes, combobox, datagridview) when a different tab is selected so when i go back to the previous tab, i don't want to see any data but rather the controls blank or refreshed. I've tried to work with selectedindexch anged but to no avail could i resolve the problem. My code looks something like this(please excuse if it looks poor as i was just messing around with the code):-
    [code=C#]
    private void tbInsertUpdateD eleteView_Selec tedIndexChanged (object sender, EventArgs e)
    {
    if (tbInsertUpdate DeleteView.Sele ctedTab == tbTeams1)
    {
    cmbTeamNo.Selec tedIndex = -1;
    txtMember1_1.Da taBindings.Clea r();
    txtMember2_2.Da taBindings.Clea r();
    txtMember3_3.Da taBindings.Clea r();
    txtMember1_1.Cl ear();
    txtMember2_2.Cl ear();
    txtMember3_3.Cl ear();
    dgvTeams.DataSo urce = null;

    }

    if (tbInsertUpdate DeleteView.Sele ctedTab == tbTeams2)
    {
    txtTeamNo.Clear ();
    txtMember1.Clea r();
    txtMember2.Clea r();
    txtMember3.Clea r();
    dgvTeams.DataSo urce = null;
    }

    if (tbInsertUpdate DeleteView.Sele ctedTab == tbTeams3)
    {
    txtTeamNo.Clear ();
    txtMember1.Clea r();
    txtMember2.Clea r();
    txtMember3.Clea r();
    cmbTeamNo.Selec tedIndex = -1;
    txtMember1_1.Da taBindings.Clea r();
    txtMember2_2.Da taBindings.Clea r();
    txtMember3_3.Da taBindings.Clea r();
    txtMember1_1.Cl ear();
    txtMember2_2.Cl ear();
    txtMember3_3.Cl ear();
    }
    }
    [/code]
    Any help would be appreciated. Thanks
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Just set everything to blank when that tabpage becomes active?
    That looks like what you are trying to do, so what is the actual problem?

    Comment

    • naseemsadak
      New Member
      • Oct 2008
      • 5

      #3
      Originally posted by Plater
      Just set everything to blank when that tabpage becomes active?
      That looks like what you are trying to do, so what is the actual problem?
      The problem is, it doesn't work. If i select another tabpage and go back to my previous tabpage, nothing becomes blank. I can still see the data I either selected or viewed in a datagrid

      Comment

      • naseemsadak
        New Member
        • Oct 2008
        • 5

        #4
        Ok let me try to make another scenario for better understanding hopefully. Say i got 2 tabs (Create Team, View Team). Now i create couple teams, and i wish to view the teams in a datagrid which i do and i can see the teams i created. Now of course i can create a button to clear the datagrid, but instead i want to go back to the create team tabpage to create another team and when i go back to view team tabpage, i want to see the datagridview automatically blank or refreshed without me having to use a button to clear the datagrid.......

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Have you set breakpoints to see if that code ever gets executed?
          I see your function that clears the databindings... .but where does it get populated?

          Comment

          • naseemsadak
            New Member
            • Oct 2008
            • 5

            #6
            Sorry for the delay in reply. Yes I did try breakpoints but still no success. I doubt this will work so I have decided to scrap the idea and work try something. Thanks for the quick responses. I do appreciate it.

            Comment

            • naseemsadak
              New Member
              • Oct 2008
              • 5

              #7
              Sorry i meant try something else

              Comment

              Working...