Link to home
Start Free TrialLog in
Avatar of Robb Hill
Robb HillFlag for United States of America

asked on

Winform Combo Box not showing correct results

I have a winform loading a combo box...and am not getting desired output in the combo box.  

the values repeat themselves with this :  AttachmentsLibrary.Attachments

Here is my class that loads the connection and creates the list to populate the datasource of the combo box.
namespace AttachmentsLibrary
{
    public class SqliteDataAccess
    {
        public static List<Attachments> LoadFormId()
        {
            using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                var output = cnn.Query<Attachments>("select Distinct Form from Attachments Order by Form Asc", new DynamicParameters());
                return output.ToList();
            }
        }      

       

        private static string LoadConnectionString(string id = "Default")
        {
            return ConfigurationManager.ConnectionStrings[id].ConnectionString;
        }
    }


}

Open in new window



Here is the code behind on my winform:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using InfoPathAttachmentEncoding;
using AttachmentsLibrary;

namespace SP2007AttachmentArchival
{
    public partial class frmDownLoadAttachments : Form
    {
        private StringBuilder sb = new StringBuilder();
        List<Attachments> attachment = new List<Attachments>();

        public frmDownLoadAttachments()
        {
            InitializeComponent();

            LoadFormList();
        }

        private void LoadFormList()
        {
            attachment = SqliteDataAccess.LoadFormId();

            WireUpFormList();
        }

        private void WireUpFormList()
        {
            cmbFormType.DisplayMember = "Display";
            cmbFormType.ValueMember = "Value";
            cmbFormType.DataSource = attachment;
        }

       
        private void btnDLFolder_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            txtDLFolder.Text = folderBrowserDialog1.SelectedPath;

        }

       
    }

}

Open in new window



As I side note I need this to display properly ..and then store the selected value so I can use it in my class.

I also probably would like some text or something like Select Form ID:  appended on the first row for UI sake.


Thanks,
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robb Hill

ASKER

Thanks!