473,657 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Forms Fatch Combobox's value Problem

KalariaNitya
34 New Member
hello all,

i need ur help..

i have 10 combobox & 10 textbox on windows forms

it's names like :

cmbsign1 txtdiscount1
cmbsign2 txtdiscount2
cmbsign3 txtdiscount3
cmbsign4 txtdiscount4
cmbsign5 txtdiscount5


i just make a for loop to fatch combobox and textbox's value
Expand|Select|Wrap|Line Numbers
  1. dim sign as new combobox
  2. dim discount as new textbox
  3.  
  4.    j=1
  5.    For i = 0 To 10
  6.                 sign = CType("cmbSign" & j, ComboBox)
  7.  
  8.                 txt.Name = "discount" & j
  9.                 discount.Text = txt.Text
  10.  
  11.                 MsgBox(discount.Text)
  12.  
  13.                 discount.Text = ("txtdiscount" & j)
  14.                 commission.Text = ("txtcommission" & j)
  15.  
  16.                 j = j + 1
  17.    Next
  18.  
i.e.
=============== =
sign = CType(cmbSign1, ComboBox) if we do like this then work but i want

sign like
sign = CType("cmbSign" & j, ComboBox)

it gives error that can not convert from string to combobox..

can anybody help me?

any help will be appriciated..

thanking u in advanced..
Jun 3 '08 #1
6 1288
shweta123
692 Recognized Expert Contributor
Hi ,

You can try this code for your requirement :

Expand|Select|Wrap|Line Numbers
  1. //variables for program
  2. string txtName="";
  3. string cmbName="";
  4. string txtValue;
  5. string cmbValue;
  6. TextBox t1 = new TextBox();
  7. ComboBox c1 = new ComboBox();
  8.  
  9. //For loop to get Textbox and Combo box values on the Form
  10. for (int i = 1; i <= 10; i++)
  11. {
  12.  
  13. //define textbox name 
  14. txtName = "txtdiscount" + i;
  15.  
  16. //define combobox name
  17. cmbName = "cmbSign" + i;
  18.  
  19. //Get textbox control
  20. t1 = (TextBox)this.Controls[txtName];
  21.  
  22. //Get combobox control
  23. c1 = (ComboBox)this.Controls[cmbName];
  24.  
  25. //Get combo box value
  26. cmbValue = c1.Text;
  27.  
  28. //Get textbox value
  29. txtValue = t1.Text;
  30.  
  31. }
  32.  
Jun 3 '08 #2
KalariaNitya
34 New Member
hi, shweta

first of all thanks..

u send me code in c# right?

i have to convert it into vb.net
Expand|Select|Wrap|Line Numbers
  1.  Dim discounttxt As New TextBox 
  2. For i = 0 To 2
  3.  
  4. Dim b As String
  5. Dim c As String
  6. b = "txtdiscount" & j
  7.  
i got the value of b
Expand|Select|Wrap|Line Numbers
  1.  discounttxt = CType(Me.Controls(b), TextBox) 
  2. c = discounttxt.Text
  3.  
  4. Next
  5.  
but can't get discounttxt.
i got value Nothing
i didn't get textbox control

do u have any idea?

thanking u in advanced....... .......
Jun 3 '08 #3
shweta123
692 Recognized Expert Contributor
Hi,

For getting the value of discounttxt you have to add following code in your existing vb .net code :

Expand|Select|Wrap|Line Numbers
  1.  Dim discounttxt as new TextBox 
  2.  
  3. For i = 0 To 2
  4. Dim b As String
  5. Dim c As String
  6. b = "txtdiscount" & j
  7.  
  8. '''''''Get textbox control here 
  9. discounttxt = CType(me.Controls(b),"TextBox")
  10.  
  11. '''''''''''Get the value of discount textbox
  12. c = discounttxt.Text
  13. Next
  14.  
Jun 3 '08 #4
KalariaNitya
34 New Member
hi shweta
first of thanks, for replying me such fast...

thanks i had done according to u. but still i didn't get textbox as NOTHING

i just try following code..
i know it bit longer then u suggested..but will work now..code as follows:
Expand|Select|Wrap|Line Numbers
  1.  
  2. For ksign = 1 To 10
  3. strsign = "cmbsign" & ksign
  4. sign = Me.Controls("pnlCategoryInfo").Controls(strsign)
  5. signvalue = sign.Text
  6. Next
  7.  
  8. 'for discount 
  9. For kdiscount = 1 To 10
  10. strdisount = "txtdiscount" & kdiscount
  11. discount = Me.Controls("pnlCategoryInfo").Controls(strdisount)
  12. Next
  13.  
  14. 'for commission 
  15. For kcommission = 1 To 10
  16. strcommission = "txtcommission" & kcommission
  17. commission = Me.Controls("pnlCategoryInfo").Controls(strcommission)
  18. Next
  19.  
once again thanks,
Jun 4 '08 #5
shweta123
692 Recognized Expert Contributor
Hi,

Where are you getting error in this code?
Jun 4 '08 #6
KalariaNitya
34 New Member
Hello,
above pasted code is perfactly working..

i had done it..

thanks 4 ur help..

i told u that b4 one was not working..

any ways, have a great day ahead..
thanks again



Hi,

Where are you getting error in this code?
Jun 4 '08 #7

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

Similar topics

2
4010
by: Cro | last post by:
Dear Access Developers, I am developing a form with 'default view' set to "continuous forms". I am suffering with a problem I can't yet see a solution too. Each record has many fields. Two fields I would like to add a little extra functionality to are a check box and a combo box. More explicitly, I would like the 'enabled' property of a combo box control to be dependent on the value of a check box (a 'yes/no' field) in the same...
1
3446
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
0
3931
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server - Select from two specific services - Check the status of the server
0
3468
by: Martin Henke | last post by:
Dear all, I've got a problem with my custom combo box. When I select an entry from it, then I get the error message: "An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values."
0
2090
by: Jake Montgomery | last post by:
I am using .NET 2.0 forms and running on Windows XP SP2. When I have a tooltip on a combo box, and the combo box is expanded (“dropped down”) using the arrow, it will no longer display it’s tooltip, no matter how long I hover. Even if I move off the control and back it will still not display its tooltip. If I then go to another control that has tootips, then back to the combobox, it will again display its tooltip, until the next time it is...
6
5603
by: Nathan Laff | last post by:
Why when I inherit a ComboBox and make no code changes, when I set the new control DropDownStyle to dropDownList it appears different than the standard ComboBox control on Vista? In Windows Vista when this mode is set, the control is all one color indicating that you can't type in it and looks really slick. How do i reproduce this behavior?
4
6661
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
3
1102
by: nityaprashant | last post by:
hello.. i have grid view.. in that template column i want to fatch product name form selected row.. i had done code like below.. but it fatch all row's product name one by one.. i want only product name for selected row..
21
3338
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters a zipcode that is unknown this form will open. I don't want users to modify any of this customers data until they close the zipcode form. Normally this can accomplished using a modal form, however this prevents me from opening a new copy of...
0
8397
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.