> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to get the category list and set category on a contact

> How to get the category list and set Contact.Category from combo box

Here we have used 2 events to get the job done. We have used one event to populate the control with categories from the list that we have retrieved and the second one for setting the category of the contact and saving the entity.

```csharp theme={null}
using SuperOffice.CRM.Services;
using SuperOffice;

private void button3_Click(object sender, EventArgs e)
{
  using (SoSession mySession = SoSession.Authenticate("SAL0", ""))
  {
    //Get the MDO agent
    using(MDOAgent mdoAgent = new MDOAgent())
    {
      SelectableMDOListItem[] categoryList =
       mdoAgent.GetSelectableList("category", false  , "", false);

      //Set the datasource of the control
      cmbCategory.DataSource = categoryList;

      //Set the display member
      cmbCategory.DisplayMember = "Name";

      //Set the value member
      cmbCategory.ValueMember = "Id";
    }
  }
}

private void button4_Click(object sender, EventArgs e)
{
  using (SoSession mySession = SoSession.Authenticate("SAL0", ""))
  {
    //Retrieve a contact agent
    using(ContactAgent contactAgent = new ContactAgent())
    {
      //Retrieve the contact entity you want through the contact agent
      ContactEntity myContact = contactAgent.GetContactEntity(4);

      //Set the category ID of the contact using selected value of the combo box control
      myContact.Category.Id = System.Convert.ToInt32(cmbCategory.SelectedValue);

      //Finally save contact entity
      contactAgent.SaveContactEntity(myContact);
    }
  }
}
```

Below is a screenshot of the application that we have developed.

![01 -screenshot][img1]

[img1]: /media/loc/en/api/web-services/image001-8.jpg


## Related topics

- [Get a CategoryList using the MDO Agent](/en/api/web-services/howto/company/get-catlist-mdoagent.md)
- [Get a CategoryList using the ListAgent](/en/api/web-services/howto/company/get-catlist-listagent.md)
- [Get Category List](/en/api/reference/restful/agent/list_agent/get-category-list.md)
- [Get Ticket Category List](/en/api/reference/restful/agent/list_agent/get-ticket-category-list.md)
- [Add a category list item](/en/api/web-services/howto/company/add-catlist-item-webapi-agents.md)
- [Add a category list item using REST](/en/api/web-services/howto/company/add-catlist-item-rest.md)
