By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,281 Members | 512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,281 IT Pros & Developers. It's quick & easy.

Refresh textbox/combobox/datagridview when multiple tabs selected

P: 5
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 selectedindexchanged 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):-
Expand|Select|Wrap|Line Numbers
  1. private void tbInsertUpdateDeleteView_SelectedIndexChanged(object sender, EventArgs e)
  2.         {
  3.             if (tbInsertUpdateDeleteView.SelectedTab == tbTeams1)
  4.             {                
  5.                 cmbTeamNo.SelectedIndex = -1;
  6.                 txtMember1_1.DataBindings.Clear();
  7.                 txtMember2_2.DataBindings.Clear();
  8.                 txtMember3_3.DataBindings.Clear();
  9.                 txtMember1_1.Clear();
  10.                 txtMember2_2.Clear();
  11.                 txtMember3_3.Clear();
  12.                 dgvTeams.DataSource = null;
  13.  
  14.             }
  15.  
  16.             if (tbInsertUpdateDeleteView.SelectedTab == tbTeams2)
  17.             {
  18.                 txtTeamNo.Clear();
  19.                 txtMember1.Clear();
  20.                 txtMember2.Clear();
  21.                 txtMember3.Clear();
  22.                 dgvTeams.DataSource = null;
  23.             }
  24.  
  25.             if (tbInsertUpdateDeleteView.SelectedTab == tbTeams3)
  26.             {
  27.                 txtTeamNo.Clear();
  28.                 txtMember1.Clear();
  29.                 txtMember2.Clear();
  30.                 txtMember3.Clear();
  31.                 cmbTeamNo.SelectedIndex = -1;
  32.                 txtMember1_1.DataBindings.Clear();
  33.                 txtMember2_2.DataBindings.Clear();
  34.                 txtMember3_3.DataBindings.Clear();
  35.                 txtMember1_1.Clear();
  36.                 txtMember2_2.Clear();
  37.                 txtMember3_3.Clear();
  38.             }
  39.         }
  40.  
Any help would be appreciated. Thanks
Oct 6 '08 #1
Share this Question
Share on Google+
6 Replies

Plater
Expert 5K+
P: 7,872
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?
Oct 6 '08 #2

P: 5
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
Oct 6 '08 #3

P: 5
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.......
Oct 6 '08 #4

Plater
Expert 5K+
P: 7,872
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?
Oct 6 '08 #5

P: 5
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.
Oct 7 '08 #6

P: 5
Sorry i meant try something else
Oct 7 '08 #7

Post your reply

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