Click here to Skip to main content
15,910,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello freinds
i am writting a program include below forms.
every photo is for one of forms.
i am using 3 layer architecture on entity framework.it's photo is in below link:
http://www.8pic.ir/viewer.php?file=17540479024128000147.jpg[^]
i have a main form :
http://www.8pic.ir/viewer.php?file=74547582891822146724.jpg[^]
there is some button on top of that.i click add button.
next form appears on the screen.
http://www.8pic.ir/viewer.php?file=66707912746213610128.jpg[^]
there are textbox and combobox and a UserControl under the form in to a panel.
i select a item in the listbox.
a user control add to my panel.
//-----------------------------------------------------------------------------

i made my question shorter.i need a guidline.
<pre lang="sql">in my code i am using a string array to save contents of listbox.i want to modify it to save contents of listbox in a datasource that it&#39;s contents be from type of a
entity.
i need to know that how i use a datasource to save temporarily a list of data in a user control which are not type of string. they should be type of a Entity.&lt;/pre&gt;</pre>
i need a thing like this picture.

<a href="http://www.8pic.ir/images/78697864078681572287.png">http://www.8pic.ir/images/78697864078681572287.png</a>[<a href="http://www.8pic.ir/images/78697864078681572287.png" target="_blank" title="New Window">^</a>]

next

<a href="http://www.8pic.ir/images/51362496456109944330.png">http://www.8pic.ir/images/51362496456109944330.png</a>[<a href="http://www.8pic.ir/images/51362496456109944330.png" target="_blank" title="New Window">^</a>]

next

<a href="http://www.8pic.ir/images/63598240075710477715.png">http://www.8pic.ir/images/63598240075710477715.png</a>[<a href="http://www.8pic.ir/images/63598240075710477715.png" target="_blank" title="New Window">^</a>]

thanks to help me.
//--------------------------------------------------------------------------------------
this was my wrong code:
c#//---------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using InspectorSys.Model;
using InspectorSys.BLL;
//my class
namespace InspectorSys.UI
{
    public partial class UcMultiChoiceResponse : UserControl
    {
        int counter = -1;
        string[] array1 = new string[500];

multichoiceresponsetype>

        MultiChoiceResponseTypeBusiness biz = new MultiChoiceResponseTypeBusiness();
        List<responsechoice> ResponseChoice = new List<responsechoice>();
        List<multichoiceresponsetype>
        ResponseChoice selectedResponseChoice;
        List<responsechoice> responceChoiceList;
        ResponseChoiceBusiness responceChoiceBiz;
        AddEditState addEditState;

        public ResponseChoice SelectedResponseChoice
        {
            get { return selectedResponseChoice; }
        }

        public UcMultiChoiceResponse(ResponseChoiceBusiness responceChoiceBiz, List<responsechoice> responceChoiceList, ResponseChoice selectedResponseChoice = null)
        {
            InitializeComponent();
        }
//when i click add button.
        private void btnResponseChoice_Click(object sender, EventArgs e)
        {

            bdsResponseChoice.EndEdit();
            txtMultiChoice.Enabled = true;
            try
            {
                if (txtMultiChoice.Text != "")
                {
                    counter++;

                    lbUcMultiChoice.Items.Add(txtMultiChoice.Text);
           multiChoiceResponseType.AddRange((MultiChoiceResponseType)txtMultiChoice.Text.ToList());
                    lbUcMultiChoice.SelectedIndex = lbUcMultiChoice.Items.Count - 1;
                    //copy in array
                    array1[counter] = txtMultiChoice.Text;
                    txtMultiChoice.Text = null;
                    txtMultiChoice.Focus();

                    lbUcMultiChoice.ClearSelected();
                    this.lbUcMultiChoice.SelectedIndex = this.lbUcMultiChoice.Items.Count - 1;

                }

                if (counter &gt;= 0)
                {
                    delbtnMultiChoice.Enabled = true;
                }
            }
            catch { };
            lbUcMultiChoice.Focus();
        }

//I click delete button
        private void button2_Click(object sender, EventArgs e)
        {
            counter--;
            for (int i = 0; i &lt; lbUcMultiChoice.SelectedItems.Count; i++)
                lbUcMultiChoice.Items.Remove(lbUcMultiChoice.SelectedItems[i]);
            this.lbUcMultiChoice.SelectedIndex = this.lbUcMultiChoice.Items.Count - 1;
            delbtnMultiChoice.Enabled = true;
            if (counter &lt; 1)
            {
                delbtnMultiChoice.Enabled = false;
            }
        }

    }

}
Posted
Updated 30-Jul-13 21:51pm
v6
Comments
ZurdoDev 29-Jul-13 11:24am    
Wow. There is way too much code and various screen shots. I doubt anyone is going to help you. You need to edit this post, narrow it way down to what your issue is. This is all volunteer and there are lots and lots of questions so you need to be more specific.
mahmoodof 31-Jul-13 5:34am    
hello ryanb31
i made my question shorter.
what is my solution?
ZurdoDev 31-Jul-13 7:40am    
What is the question?
ridoy 29-Jul-13 12:40pm    
right say @ryanb31
nikhil-vartak 30-Jul-13 0:34am    
Completely agreed with ryanb31

1 solution

hello
my problem was in my datasourse.
i could solve it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900