Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6182405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:11:38+00:00 2026-05-24T01:11:38+00:00

I am doing Student Attendance project for college in win form with MySQL(C#). I

  • 0

I am doing Student Attendance project for college in win form with MySQL(C#).

I already ask Hidden Column in Listbox i got the Solution for that.

Updated Query –

string MyConString = ConfigurationManager.ConnectionStrings["College_Management_System.Properties.Settings.cmsConnectionString"].ConnectionString;
                MySqlConnection connection = new MySqlConnection(MyConString);
                string cnd1 = "select name,admin_no from student_admision_master where course='" + course_code + "' AND year='" + year_code + "' AND sem='" + semester_code + "' AND batch='" + batch_code + "'";
                MySqlDataAdapter da = new MySqlDataAdapter(cnd1, connection);
                connection.Open();
                DataSet ds = new DataSet();
                MySqlCommand command = connection.CreateCommand();
                da.Fill(ds, "student_admision_master");
                //dataGridView1.DataSource = ds.Tables[formName];
                listBox1.DataSource = ds.Tables[0].DefaultView;
                listBox1.DisplayMember = "name";
                listBox1.ValueMember = "admin_no";
                connection.Close();

I Got the Student Name in LIstbox. but,.. Listbox to Listbox moving code throw error,..

// All the Listbox2 items r moved to Listbox 3

  private void btn_toOd_Click(object sender, EventArgs e)
            {
                int count = listBox2.Items.Count;
                for (int i = 0; i < count; i++)
                {
                    listBox3.Items.Add(listBox2.Items[i].ToString());
                }
                listBox2.Items.Clear();
            }

// All the Listbox3 items r moved to Listbox 2

private void btn_fromOd_Click(object sender, EventArgs e)
{
int count = listBox3.Items.Count;
for (int i = 0; i < count; i++)
{
listBox2.Items.Add(listBox3.Items[i].ToString());
}
listBox3.Items.Clear();
}

// Selected Items only Move..

 private void btn_toAb_Selected_Click(object sender, EventArgs e)
        {
            int count = listBox1.SelectedItems.Count;
            for (int i = 0; i < count; i++)
            {
                listBox2.Items.Add(listBox1.SelectedItems[i].ToString());
            }

            for (int i = 0; i < count; i++)
            {
                listBox1.Items.Remove(listBox1.SelectedItems[0]);
            }
        }

        private void btn_fromAb_Selected_Click(object sender, EventArgs e)
        {
            int count = listBox2.SelectedItems.Count;
            for (int i = 0; i < count; i++)
            {
                listBox1.Items.Add(listBox2.SelectedItems[i].ToString());
            }

            for (int i = 0; i < count; i++)
            {
                listBox2.Items.Remove(listBox2.SelectedItems[0]);
            }
        }

Items collection cannot be modified when the DataSource property is
set. in ARGUMENT EXCEPTION.

How Can i move item collection in Listbox1 to Listbox2,.

And How Can i access the particular ValueMember(admin_no) from the Listboxes.

bzs i want to save the record based on the admin_no.

Is the info is enough or can i add the picture here,..

Please Give an idea to do this!…

Thanks in advance….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:11:39+00:00Added an answer on May 24, 2026 at 1:11 am

    Your list box is databound – this means, the items in the list box are automatically managed by the binding manager. You can not really move items around the way you do it.

    Instead, you need to modify the underlying data source accordingly. That means: Do not add/delete items to/from the list boxes, but to/from the underlying data set.

    Every item in the list box is either a DataRow or a DataRowView, which has a Row property to access the underlying DataRow. Once you have access to the DataRow you can determine field values using row['fieldname'].

    To move a row from one dataset to another, you will have to use the ImportRow method on the destination table to add the row. Then you have to remove the row from the source table. Sample (which you may have to play around with a bit, as I haven’t tried it right now):

    DataRow row = listBox.SelectedItem;
    /* The above may need to be changed to
       DataRow row = (listBox.SelectedItem as DataRowView).Row;
       in case the SelectedItem is a DataRowView instead of a DataRow
     */
    destDataSet.Table.ImportRow(row);
    sourceDataSet.Table.Remove(row);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing Student Attendance project for college in win form with MySQL(C#). see
I am doing Win-form project with MySQL. In My Problem is,.. I want to
I'm a college student doing a Java homework. I've created this program that allows
I am student and i am doing project of Order Accepting system for five
I'm a student doing an extra-grade project, and my prof has asked me to
I've got a table of student information in MySQL that looks like this (simplified):
Firstly I am no longer a student and doing this for other purposes, so
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing code analysis of the project and get the message Reference-counted object is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.