473,769 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bind TextBox to Selected Item of ListBox

Hello All

I have a textbox control. I would like this text box to automatically
update to contain the currently selected item located in a listbox
which is on the same form.

Do I need a CurrencyManager for this? Can this be done just by
manipulating the databindings properties of the textbox? If so, please
do give me some hints as to the syntax I would use to fill in that
field on the property panel - everything I try is rejected.

Disclaimer: No this is NOT my homework. I'm 45 years old, new to
CSharp and quite capable of digging most things up on the net for
myself. I just cannot seem to make this work. A few code snippets
would be much appreciated. Obviously I could code a manual procedure
for this - but hey CSharp is supposed to automate this sort of thing
(I think) and I wanna know how its done. I have seen all of the
dataset binding examples - nothing seems to work on the listbox to
textbox pair.

Cheers
Old Newbie
Nov 17 '05 #1
2 9603
From one old git to another :-)

You could use the SelectedIndexCh anged event on the listbox to update the
textbox:-
private void listBox1_Select edIndexChanged( object sender, System.EventArg s
e)

{

this.textBox1.T ext = this.listBox1.S electedItem.ToS tring();

}

Regards,

Gras

"OldNewbie" <No****@NoSpam. com> wrote in message
news:4e******** *************** *********@4ax.c om...
Hello All

I have a textbox control. I would like this text box to automatically
update to contain the currently selected item located in a listbox
which is on the same form.

Nov 17 '05 #2
On Sun, 6 Nov 2005 11:46:23 +0100, "La Grasserie"
<newsatthe-farrs.com> wrote:

Ahh.... of course. So simple! Thank you.

Eventually I'm going to have to get to grips with the data binding and
CurrencyManager stuff but that can be put off to another day.

Cheers muchly
OldNewbie
From one old git to another :-)

You could use the SelectedIndexCh anged event on the listbox to update the
textbox:-
private void listBox1_Select edIndexChanged( object sender, System.EventArg s
e)

{

this.textBox1. Text = this.listBox1.S electedItem.ToS tring();

}

Regards,

Gras

"OldNewbie" <No****@NoSpam. com> wrote in message
news:4e******* *************** **********@4ax. com...
Hello All

I have a textbox control. I would like this text box to automatically
update to contain the currently selected item located in a listbox
which is on the same form.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12920
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected value which is included in the listbox's filtering statement. Is the only way to do this is to dispose the dataview and then create a new one and then bind it to the listbox? Is there a better way than this? Thanks, Alpha
0
1925
by: VbScripter | last post by:
In the code below, I have an editItemTemplate that will have to have a long list of ip's bound to it. The problem is that the lisbox is not seen by asp.net until after the datalist containing it is exposed. Is there a way to bind the ddl inside of an already databound templated column? Thanks , of course Michael
3
2948
by: me | last post by:
Is there any particular reason why a requiredfieldvalidator cant validate a listbox? I have bound the two together but the validator always returns false on isvalid and so does the Page, no matter if the user selects an item in the listbox or not.
12
4399
by: amber | last post by:
Hello, I'm going around in circles with this problem and I hope someone can help me. I have a listbox that is populated from a SQL Server database, with about 600 items, all strings. I have a textbox on the same form, where I want to display which item is selected. In the 'OnSelectedIndexChanged' event, I need code that has the textbox update to whatever value is currently selected in the listbox. If I use the code:
9
3249
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this selection. I am using an SQLDataSource web control for this. These items are headers. I want, when...
1
6435
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes for the non-foreign key fields. When the user clicks on a row in the listbox, the comboboxes' SelectedItem changes to reflect the foreign key selections in the currently selected row. That part is working fine. I also want the textboxes to change to...
4
2879
Mohan Krishna
by: Mohan Krishna | last post by:
Hi Everyone, I'm working with a project, in which i used a listbox and textbox as a combination. Hoping anyone would help me, i explianed my problem:- There is a list of companies (sorted or not) in a listbox. While typing in textbox, as per each letter is being typed, the company names in the list MUST BE SELECTED. For eg: In Textbox In Listbox M List starting with M should be selected. Mi ...
2
2743
by: E11esar | last post by:
Hi there. I am looking to use a dataset return from a webservice that is currently populating a listbox, to also populate a value in a textbox that is loaded once an item is selected from the listbox. My code for the above part that populates the listbox is as follows and this works fine. listBox.DataSource = myWebService.MethodName(param1, param2); listBox.DataValueField = "RETURN_DETAILS_ONE"; listBox.DataBind();
2
3920
by: akshalika | last post by:
Hi, I have a repeater control. it dynamically bind textbox or dropdown base on some condition. i want to bind required field validator dynamically for validate textbox or dropdown. here is my aspx design <asp:Repeater ID="repeaterItemAttribute" runat="server" OnItemDataBound="repeaterItemAttribute_ItemDataBound"> <ItemTemplate> <li> ...
0
10199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9981
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
9850
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
8862
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
7396
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
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
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...
3
2810
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.