Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / June 2005

Tip: Looking for answers? Try searching our database.

ListView and Bound DataSet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
eXtreme - 06 Jun 2005 11:47 GMT
I have a dataset bound listbox with items that I want to give the user the
ability to reorder.

For some reason... unknown right now... the listbox does not properly update
from the dataset when I update the dataset... even after I accept changes
and write the dataset out to XML.

When I dump the dataset to the Console the data appears to be in the correct
order.

What method would I called to tell the ListBox to refresh from the dataset?
"Jeffrey Tan[MSFT]" - 07 Jun 2005 06:08 GMT
Hi eXtreme,

Thanks for your post.

First, do you use ListView or ListBox in your application? You mentioned
ListView in the post title, however, ListBox in the content. Currently, I
assume you use ListBox.

Normally, we can re-order the databinding with setting a sort expression in
DataView.Sort property. I have writen a little sample project for your
scenario, however, it works well for re-ordering and updating. Code snippet
listed below:

private DataTable dt=null;
private void Form1_Load(object sender, System.EventArgs e)
{
    dt=new DataTable();
    dt.Columns.Add(new DataColumn("column1", typeof(int)));
    dt.Columns.Add(new DataColumn("column2", typeof(string)));

    for(int i=0;i<6;i++)
    {
        DataRow dr=dt.NewRow();
        dr["column1"]=i;
        dr["column2"]="item"+i.ToString();
        dt.Rows.Add(dr);
    }
    this.listBox1.DataSource=dt;
    this.listBox1.DisplayMember="column2";
    this.listBox1.ValueMember="column1";
}

private void button1_Click(object sender, System.EventArgs e)
{
    this.dt.Rows[3]["column1"]="7";
    this.dt.Rows[3]["column2"]="item7";
    this.dt.DefaultView.Sort="column1 DESC";
}
===========================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

"Jeffrey Tan[MSFT]" - 09 Jun 2005 07:08 GMT
Hi eXtreme,

Does my reply make sense to you? If you still have anything unclear, please
feel free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.