I m new to C# and visual studio
My promblem is the following:
In a form i have a list box and a text box
i have connected the listbox datasource property with an access database file and listbox displays all the contents of the database.
I want to copy the contents of the listbox to an array
I use the following command
listbox1.Items.CopyTo(aa, 0);
all the values of the array takes the value of the type name of the objects in the list instead of the value of the property in the object which is the following value:
System.Windows.Forms.ListBox + ObjectCollection
how can i take the actual value of the items of the listbox in my array. I really feel i m in a dead end
This is my whole code
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace food1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pRODUCTSBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.pRODUCTSBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.foodsDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'foodsDataSet.PRODUCTS' table. You can move, or remove it, as needed.
this.pRODUCTSTableAdapter.Fill(this.foodsDataSet.PRODUCTS);
object[] aa = new object[80];
listbox1.Items.CopyTo(aa, 0);
textBox1.Text = aa[1];
}
}
}