Robb Hill
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.Attachm ents
Here is my class that loads the connection and creates the list to populate the datasource of the combo box.
Here is the code behind on my winform:
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,
the values repeat themselves with this : AttachmentsLibrary.Attachm
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;
}
}
}
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;
}
}
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER