---
title: "Accessing ComboBox text/value in another Form"  
description: "Accessing ComboBox text/value in another Form"  
author: "Anonymous User"  
published: 2013-12-17  
updated: 2013-12-17  
canonical: https://www.mindstick.com/forum/1791/accessing-combobox-text-value-in-another-form  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Accessing ComboBox text/value in another Form

I want to get the chosen [language](https://www.mindstick.com/startup/28/preply-the-fast-growing-platform-transforming-language-learning) from the Form1 [combobox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) and enable other forms to view the language. The combobox has approximately 20 languages.

I have a [method called](https://www.mindstick.com/interview/2613/when-does-onresume-method-called) ComboBoxLang_SelectedIndexChanged (occurs when the language in the combobo is changed):

```
// Works fine in Form1.csprivate void ComboBoxLang_SelectedIndexChanged(object sender, EventArgs e){    string selectedItem = this.comboBoxLang.GetItemText(this.comboBoxLang.SelectedItem);    comboBox2.Items.Clear();    if (selectedItem == Language.English)    {        ToEnglish();    }    else if (selectedItem == Language.French)    {        ToFrench();    }    // And so on...}
```

For the moment, to test that it works I just want to display a [message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) of the language chosen in another form. I have researched and have tried [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) ways, but obviously I am going wrong somewhere! For example:

```
internal string comboBoxVal{    get    {        return comboBoxLang.SelectedItem.ToString();    }}
```

But this [comes up](https://answers.mindstick.com/qa/45369/if-you-search-worst-bollywood-actor-on-google-guess-whose-name-comes-up) with an error: "[NullReferenceException](https://www.mindstick.com/forum/159752/what-is-a-nullreferenceexception-and-how-can-you-prevent-it-in-your-dot-net-core-application) was unhandled, Object [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) not set to an [instance of an object](https://www.mindstick.com/forum/376/system-nullreferenceexception-object-reference-not-set-to-an-instance-of-an-object)".

## Replies

### Reply by Pravesh Singh

Hi Ankita,\
You can try this:\

```
public static class LanguageChangeObserver{    public static
object _lock = new object();    public delegate
void LanguageHandler(string lang);    public static
event LanguageHandler LanguageChanged;    public static
void  Notify(string lang)    {        lock (_lock)        {            if (LanguageChanged != null)               
LanguageChanged(lang);        }    }}
```

With this, all forms can subscribe to the event LanguageChanged and the form Form1 can "notify" - all other forms will get the info.


---

Original Source: https://www.mindstick.com/forum/1791/accessing-combobox-text-value-in-another-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
