-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combobox text property Not Working #348
Comments
I suggest using private List<string> CmbDataSource;
private string ComboSelectedValue { get; set; }
// your other code
// This method you will call in your class constructor, or anywhere else
private void SetComboboxDataSource()
{
CmbDataSource = new List<string>();
CmbDataSource.Add("Some First Value");
CmbDataSource.Add("Some Second Value");
CmbMaterialCombobox.DataSource = CmbDataSource;
}
// Other code here
private void CmbMaterialCombobox_SelectedIndexChanged(object sender, EventArgs e)
{
if (CmbMaterialCombobox.SelectedIndex == -1)
{
ComboSelectedValue = string.Empty;
return;
}
ComboSelectedValue = CmbMaterialCombobox.SelectedValue.ToString();
// here you can do other things with this selected value
} PS: I'm not on a computer with VS, so I didn't test this code, I hope it is written well 🙂 |
thank you,
I do it this way, I tried other methods, but I didn't get the request.
|
var selValue = (materialComboBox1.SelectedItem as Employee)?.Name; // here is your record from your cell's grid
var find = ((List<Employee>)materialComboBox2.DataSource).AsEnumerable().Where(r => r.Name.Equals(selValue)).First();
materialComboBox2.SelectedItem = find; I think is more simple to create a |
@talhayksk , some news about this issue? Did you managed to make it work on your side? If so, you may close this issue. |
I am sorry,Unfortunately, it did not happen |
I will make some tests on my side with datagridview and I will come back with a feedback. |
Thank you very much for your attention. I will be waiting |
One more question, to understand what exactly do you want to do there: BTW, I checked on my side and if the value of the cell exists in combobox datasource, then it will change the SelectedValue to me (also displays correctly the value of combobox). As a checking option, add this code |
Hi @valimaties , first of all, I'm sorry, I couldn't get back to you because of the issues that developed out of my will for a long time. I solved the problem in line with the information you gave, thank you, in this case, we can close this issue. |
hello, I want to add data to Combobox text property but I can't set it. (materialCombobox1.Text="example") this method doesn't work.
The text was updated successfully, but these errors were encountered: