I am trying to get all the values from a multi-select listbox stored into a string variable. The multi-select listbox has the group name and its corresponding group ID. I need to have the group name displayed, but when the user selects the group name, it stores the group ID value into a CSV format variable ("23,8,4,13").
I've been trying to text using a text box, but so far have been only to return just one value.
I get the group name and values from a GET request.
private void Form1_Load(object sender, EventArgs e)
{
//Makes the request to API when the form loads
Request rClient = new Request();
//endpoint is to GET the groups
rClient.endPoint = rClient.endPoint + "groups";
rClient.httpMethod = httpVerb.GET;
string strResponse = string.Empty;
strResponse = rClient.makeRequest();
List<RootObject> grpName = JsonConvert.DeserializeObject<List<RootObject>>(strResponse);
lstbxGroups.ValueMember = "id";
lstbxGroups.DisplayMember = "name";
lstbxGroups.DataSource = grpName;
lstbxGroups.SelectedIndex = -1;
}
private void btnAdd_Click(object sender, EventArgs e)
{
foreach (object item in lstbxGroups.SelectedItems)
{ txtbxTest.Text = lstbxGroups.SelectedValue.ToString(); }
}
Would someone please help me or direct me in the right direction to get the selected values? Thanks much in advanced!