473,385 Members | 1,356 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.

Autosave on SelectedIndexChanged?

Hi,
Is there a way to call a method on index A as soon as the user clicks
on index B in a ListBox?
This is my particular scenario: I have a ListBox of records in one
panel and a TextBox containing Text associated with
ListBox.SelectedIndices[0]. I want the record to be updated (in an
ArrayList, file, whatever) as soon as that index is no longer selected.
I do not want the user needing to click a Save button.
Thank you.

Nov 17 '05 #1
1 2194
You want databinding.
Say we have a simple class:

class ClassA
members - string name
methods - public override ToString(){return name;}
// the override is so that the name is shown in the listbox when used as
datasource
// as the listbox displaymember defaults to ToString()

ClassA ca = new ClassA("AName");
ArrayList al = new ArrayList();
al.Add(ca);
this.listBox1.SelectedIndexChanged+=new EventHandler(list_IndexChanged);
this.listBox1.DataSource = al;

private void list_IndexChanged(object sender, EventArgs e)
{
if(null != this.listBox1.SelectedItem)
{
this.textbox1.DataBindings.Clear();
ClassA ca = (ClassA) listBox1.SelectedItem;
this.textbox1.DataBindings.Add("Text", ca, "Name");
//// usage is property to map to ("Text") object to map (ca) and property to
map ("Name")
}
}

This will update the changes as soon as the textbox is modified.
This is just psudeo code so it might not work if you copy and paste but the
concept is there.

HTH

Jax

"I_Chameleon" <na***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,
Is there a way to call a method on index A as soon as the user clicks
on index B in a ListBox?
This is my particular scenario: I have a ListBox of records in one
panel and a TextBox containing Text associated with
ListBox.SelectedIndices[0]. I want the record to be updated (in an
ArrayList, file, whatever) as soon as that index is no longer selected.
I do not want the user needing to click a Save button.
Thank you.

Nov 17 '05 #2

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

Similar topics

1
by: p-nut | last post by:
newbie here needing some help. Is there a way to set up a script that will check a pop3 account and autosave the file attachments to a folder specified? The thing is: I have 1 single email...
0
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged....
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
7
by: jaYPee | last post by:
I am using dataset as a datasource for my datagrid. I'm wondering how to program to autosave the changes made in a datagrid just like microsoft access. any help is greatly appreciated.
2
by: Groove | last post by:
Hey guys - I've used the Thread.Sleep(xyz) method before to trigger a pause in a sub or function. I was wondering if anyone knew of a method to have a page autosave itself after X minutes? ...
4
by: lakepeir | last post by:
Hello, I have combobox with a selectedindexchanged method that seems to be called when starting the application, launching the form with the combobox and making a change in the drop down box of...
3
by: John Wright | last post by:
I want to create an autosave and crash recovery module for my program. I imagine I would have to use a timer control on the form to call the autosave functionality but I need a starting point. I...
1
by: prinsipe | last post by:
hi all, how can i autosave edited values from my datagrid when the user moves from page to page? i am using template column, textbox is used in item for the user to update the values. is...
2
by: yuvang | last post by:
I have one MDB which is located in server and so many persons are accessing and adding data to that mdb. Here is my doubt 1. is ms access has autosave option? 2. If yes, in what time interval it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.