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

TabControl and ComboBoxes C#

I am trying to read in information from a file and set certain ComboBox's initial value according to what was read in. I am using
combobox.SelectedValue = (value read in)
and all is fine and dandy. However I want to put this combo box inside the second Tab on my application, when I do that it will not set the ComboBox's SelectedValue. Why will it do it in the first tab and not in the second? Anyone know ways around this or what I might be doing wrong?
Jul 10 '08 #1
4 2793
nmsreddi
366 256MB
Hello

whether you use first tab or second tab you will get correct data , you have use particular tab page and control name in your coding

better to post your code ,other wise how can i say any mistake in your current code.
Jul 10 '08 #2
Hello

whether you use first tab or second tab you will get correct data , you have use particular tab page and control name in your coding

better to post your code ,other wise how can i say any mistake in your current code.
Expand|Select|Wrap|Line Numbers
  1. public void populateBox(ComboBox cb, dataType[] source, int offset)
  2.         {
  3.  
  4.             cb.DataBindings.Clear();
  5.             cb.DataSource = source;
  6.             cb.DisplayMember = "name";
  7.             cb.ValueMember = "enumVal";
  8.             cb.DataBindings.Add("SelectedValue", source, "name");
  9.             cb.SelectedValue = HexToAscii(buffer, offset, 1); //I know that it works because it works on the first tab
  10.         }
  11.  
This is my first C# program so it might be messy. However there is alot of combo boxes I would be using in this program so I wrote this little function. When the combo box is on the first tab it has no problem changing the selectedvalue. However it is on the second tab it does. Also I noticed if I make a combobox on the 2nd tab with the same DataSource and change that it will update the box on the first tab. It will only do it vica versa if I have navigated to the 2nd tab once.
Jul 10 '08 #3
nmsreddi
366 256MB
Hello

better once you check the name of the combobox in the second TAB ,you cannot use the same common function for different combo boxes with different names

i think you are using the same name in the code .

just check it out.
Jul 11 '08 #4
Hello

better once you check the name of the combobox in the second TAB ,you cannot use the same common function for different combo boxes with different names

i think you are using the same name in the code .

just check it out.
Why can't I use a function to set the combo boxes? I send each seperate combo box to the function... You don't type in very good english so the rest is kind of confusing to me... Some more code but I don't know what good it will do...
Expand|Select|Wrap|Line Numbers
  1. populateBox(combobox1, data1, 280);
  2. populateBox(combobox2, data2, 282);
combobox1 which is in my first page of my tab control gets set. However combobox2 in my 2nd page of my tab control doesn't get set. If I move the combobox2 to my first page it will get set. Why is this?

Sorry for posting twice it was an accident. I couldn't find my original post and I thought it got deleted or something....
Jul 11 '08 #5

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

Similar topics

6
by: LSemos | last post by:
I am trying to lookup phone numbers in a separate table based on the name in the current Tab control tblContacts has the fields: Name, Phone, Fax, and Email In my Form's Tab control, I have...
5
by: Tamir Khason | last post by:
How be able to manage more deeply UI of TabControl and TabPage For example - I want to manage border color, change color of TabPage reef, eliminate spaces from both sides of the reef, so I bould...
1
by: Tom aka The Coolest Dolphin | last post by:
Hi all, I have a question where I cannot find an answer for honestly.... I've created a tabControl on my form with one tab filled with 11 textboxes & 22 comboboxes, all layed out nice. Did much...
2
by: Patrick McGuire | last post by:
I want to place a tabControl with almost identical properties on several forms. I think the best way is to define a UserControl that inherits System.Windows.Forms.TabControl, and place all my...
3
by: Hanika | last post by:
Hello All. I am having a very strange thing happening with my control on a TabControl. I have several tabs that I show depending on what the user selects. My controls behave differently if I show...
9
by: Michael Turner | last post by:
Hi Guys Having problem with the tab control, I need to set the background color to something different than the standard, I have found code on the web and now can redraw the tabpage buttons so...
5
by: Zadkin | last post by:
Does anyone know, if it's possible to set the orientation of the tabpagebuttons to horizontal instead of vertical when the alignment property of my tabcontrol is set to left or right? Thanks in...
8
by: Gregory A Greenman | last post by:
I have a minor, but somewhat frustrating, problem. In a program I'm working on, I've got a tabcontrol that contains several other controls, a few of which are comboboxes. In the IDE, one of the...
0
by: daveryan78 | last post by:
Hi all, I've been getting a strange problem with anchoring on my forms. I have a form where I put on a tabControl. I set it's anchoring to Top, Bottom, Left, Right. I put a number of tabPages on...
1
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all In a Visual Studio 2005 C# project, I have a simplest tabcontrol with two tabpages. When I set tab control's Alignment property to Right, tab texts (captions) disappear. Does anybody...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.