Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2004, 02:13 PM
Authorized User
 
Join Date: Aug 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Alcapone
Default Listbox selecteditem to string

Hi,

I am tried to do the follwing but am keep getting erros.

This is what i tried:

I have a listbox containing the a few courses. By selecting a course i get the option to create a word document that contains the course name showed in the listbox.

string cursist = lstb_course.SelectedItem.ToString();
ThisApplication.Selection.TypeText(cursist);

only when i open the document is shows System.Data.DataRowView instead of the course name.

any idea's how this can happen.
 
Old October 27th, 2004, 06:08 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you add items to the list box, how do you do it?

Kep.
 
Old October 28th, 2004, 02:18 AM
Authorized User
 
Join Date: Aug 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Alcapone
Default

I use the following statement:

            string strconn = System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"].ToString();
            SqlConnection conn = new SqlConnection(strconn);
            string fillcmd = "SELECT Course.Name , Course.Type , Course.Points" + " " +
                "FROM StudyPoints INNER JOIN Course ON StudyPoints.Study_uno = Course.Study_uno" + " " +
                "WHERE StudyPoints.Trainee_uno = (select Trainee_uno from Trainees where dbo.Trainees.lastname = '" + txt_search.Text + "'" + " " +
                "or dbo.Trainees.Firstname = '" + txt_search.Text + "'" + " " +
                "or dbo.Trainees.Firstname + ' ' + dbo.Trainees.Lastname like '%" + txt_search.Text + "%')";
            SqlDataAdapter da = new SqlDataAdapter(fillcmd, conn);
            DataSet ds = new DataSet();
            da.Fill(ds, "Course");
            //binds the listbox with the study the trainee has followed
            lstb_course.DataSource = ds;
            lstb_course.DisplayMember = "Course.Name";
            lstb_course.ValueMember = "Course.Type";
            lstb_course.DataBindings.Add(new Binding("Text",ds,"Course.Name"));
            lstb_course.DataBindings.Clear();





Similar Threads
Thread Thread Starter Forum Replies Last Post
Listview SelectedItem Apocolypse2005 Visual Basic 2005 Basics 1 October 28th, 2007 01:08 PM
Place string values into ListBox semilemon C# 2005 2 April 13th, 2007 06:36 PM
Can't EASILY set cbo.selecteditem using VALUE Ron Howerton Visual Basic 2005 Basics 5 December 14th, 2006 04:52 PM
SelectedItem in ComboBox miguel.ossa C# 1 September 28th, 2004 06:50 PM
SelectedItem.Value vs. SelectedItem.Text bekim BOOK: Beginning ASP.NET 1.0 2 June 17th, 2004 07:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.