Click here to Skip to main content
15,906,708 members
Home / Discussions / C#
   

C#

 
GeneralRe: chat application Pin
Member 107629805-Jun-14 20:08
Member 107629805-Jun-14 20:08 
GeneralRe: chat application Pin
Mycroft Holmes5-Jun-14 22:31
professionalMycroft Holmes5-Jun-14 22:31 
GeneralRe: chat application Pin
Member 107629806-Jun-14 9:48
Member 107629806-Jun-14 9:48 
AnswerRe: chat application Pin
ZurdoDev5-Jun-14 16:20
professionalZurdoDev5-Jun-14 16:20 
GeneralRe: chat application Pin
Mycroft Holmes5-Jun-14 22:29
professionalMycroft Holmes5-Jun-14 22:29 
GeneralRe: chat application Pin
ZurdoDev6-Jun-14 1:24
professionalZurdoDev6-Jun-14 1:24 
AnswerRe: chat application Pin
Marco Bertschi6-Jun-14 9:21
protectorMarco Bertschi6-Jun-14 9:21 
GeneralRe: chat application Pin
Member 107629806-Jun-14 9:42
Member 107629806-Jun-14 9:42 
QuestionI can not convert WriteAllBytes to something can be used Progress Bar?? Pin
Hades104-Jun-14 1:27
Hades104-Jun-14 1:27 
AnswerRe: I can not convert WriteAllBytes to something can be used Progress Bar?? Pin
Richard MacCutchan4-Jun-14 2:48
mveRichard MacCutchan4-Jun-14 2:48 
GeneralRe: I can not convert WriteAllBytes to something can be used Progress Bar?? Pin
Eddy Vluggen4-Jun-14 2:58
professionalEddy Vluggen4-Jun-14 2:58 
GeneralRe: I can not convert WriteAllBytes to something can be used Progress Bar?? Pin
Hades104-Jun-14 4:15
Hades104-Jun-14 4:15 
SuggestionRe: I can not convert WriteAllBytes to something can be used Progress Bar?? Pin
GuyThiebaut4-Jun-14 6:21
professionalGuyThiebaut4-Jun-14 6:21 
QuestionProblem with Deleting rows in MSI database - with particular value reference alone Pin
Mohan Subramani3-Jun-14 23:19
Mohan Subramani3-Jun-14 23:19 
AnswerRe: Problem with Deleting rows in MSI database - with particular value reference alone Pin
Mohan Subramani4-Jun-14 3:09
Mohan Subramani4-Jun-14 3:09 
GeneralILMerge is not working Pin
Ashfaque Hussain3-Jun-14 20:07
Ashfaque Hussain3-Jun-14 20:07 
SuggestionRe: ILMerge is not working Pin
Richard MacCutchan3-Jun-14 21:56
mveRichard MacCutchan3-Jun-14 21:56 
GeneralRe: ILMerge is not working Pin
Ashfaque Hussain3-Jun-14 23:12
Ashfaque Hussain3-Jun-14 23:12 
GeneralRe: ILMerge is not working Pin
Richard MacCutchan3-Jun-14 23:26
mveRichard MacCutchan3-Jun-14 23:26 
GeneralRe: ILMerge is not working Pin
Ashfaque Hussain4-Jun-14 0:58
Ashfaque Hussain4-Jun-14 0:58 
SuggestionRe: ILMerge is not working Pin
Dan Colasanti6-Jun-14 5:26
professionalDan Colasanti6-Jun-14 5:26 
QuestionNAudio display multiple items in mainform listbox Pin
doby483-Jun-14 12:25
doby483-Jun-14 12:25 
I have researched this for two days and have been unable to find an answer. I'm certain I'm not the only person that wants to display more than one item in the mainform listbox of NAudio so hopefully someone here can tell me what I'm doing wrong. I need to output the results of an array to my listbox. If I use the below code then everything outputs but on a single line, instead of separate ones as I need the user to be able to select the results. I'm assuming that this is because the results are passed over in a single string despite the foreach loop.

mainform.cs

C#
[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<AudioPlugin> content)
{
    InitializeComponent();
    listBox.DisplayMember = "Name";
    foreach (var listing in content)
    {
        listBox.Items.Add(listing);
    }
}


recordingpanel.cs

C#
[Export(typeof(INAudioPlugin))]
    public class RecordingPanelPlugin : AudioPlugin
    {
        private string _customer { get; set; }

        public void ConnectionString()
        {
            using (var conn = new SqlCeConnection("Data Source=MyDatabase.sdf;Password=pass;Persist Security Info=True"))
            {
                conn.Open();
                var comm = new SqlCeCommand("SELECT * FROM main", conn);
                SqlCeDataReader reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    _customer += (string)(reader["CustomerName"]);
                }
            }
        }


        public string Name
        {
            get
            {
                ConnectionString();
                return _customer;
            }
        }

        public Control CreatePanel()
        {
            return new RecordingPanel();
        }
    }


I also tried the above using a struct, List and array with the same results each time. I'm going on the assumption that this INAudioPlugin is changing the data type during ImportingConstructor. So I tried to use the query directly in the mainform.cs. I was able to get the listbox appearing correctly but I cannot get the listbox_SelectedIndexChanged to function propery as that fails at the following line since the listbox contents are string and not INAudioPlugin it looks like. I can't explicitly convert the type either.

var plugin = (INAudioPlugin)listbox.SelectedItem;


I am completely out of ideas at this point, I hope someone can offer me a solution. I have a feeling the second route I tried is going to be where I need to go with this but I can't figure out how to call my recordingpanel.cs if I do so because of the plugin error above. Below is the code I used for the second route I tried.

mainform.cs

[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<INAudioPlugin> content)
{
    InitializeComponent();

    using (var conn = new SqlCeConnection("Data Source=MyDatabase.sdf;Password=pass;Persist Security Info=True"))
    {
        conn.Open();
        var comm = new SqlCeCommand("SELECT * FROM main", conn);
        SqlCeDataReader reader = comm.ExecuteReader();

        while (reader.Read())
        {
            _customer = (string)(reader["CustomerName"]);
    listbox.Items.Add(_customer);
        }
    }
}

private INAudioPlugin currentPlugin;

private void listbox_SelectedIndexChanged(object sender, EventArgs e)
{
    var plugin = (INAudioPlugin)listbox.SelectedItem;
    if (plugin != currentPlugin)
    {
        this.currentPlugin = plugin;
        DisposeCurrentListing();
        var control = plugin.CreatePanel();
        control.Dock = DockStyle.Fill;
        contentPanel.Controls.Add(control);
    }
}

AnswerRe: NAudio display multiple items in mainform listbox Pin
Matt T Heffron3-Jun-14 14:12
professionalMatt T Heffron3-Jun-14 14:12 
GeneralRe: NAudio display multiple items in mainform listbox Pin
doby484-Jun-14 9:25
doby484-Jun-14 9:25 
Questionbutton in circle shape Pin
KD Palekar3-Jun-14 8:34
KD Palekar3-Jun-14 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.