Note that there are some explanatory texts on larger screens.

plurals
  1. POBest method of getting the string value from the combobox to be used in database comparison
    text
    copied!<p>I have a combobox that is populated on the form load event. Of course the values are string format. They info is displayed 1-info in the combobox. I want to take that first digit and compare it to a value in my database. Based off which value it finds then populates the fields on the form. Here is what I have so far. I have been able to figure out as far as converting it back to int 32.</p> <pre><code>if (cmboBoxPreviousVersion.SelectedItem != null) { string[] s = cmboBoxPreviousVersion.Items[cmboBoxPreviousVersion.SelectedIndex].ToString().Split(' '); int id = Convert.ToInt32(s[0]); Item.FormatID = data.FormatID; Item.FormatName = data.FormatName; Item.FormatDescription = data.FormatDescription; Item.StockID = data.StockID; Item.PrintPlantCode = (bool)data.PrintPlantCode; Item.PrintWeight = (bool)data.PrintWeight; Item.PrintPrice = (bool)data.PrintPrice; rChkBoxPlantCode.Checked = Item.PrintPlantCode; rChkBoxPrintPrice.Checked = Item.PrintPrice; rChkBoxWeight.Checked = Item.PrintWeight; cmboBoxStock.Items.Add(Item.StockID); rTxtBoxDescription.Text = Item.FormatDescription; } rChkBoxPlantCode.Enabled = false; rChkBoxPrintPrice.Enabled = false; rChkBoxWeight.Enabled = false; </code></pre> <p>Any suggestions? Thank you before hand. If you need any other info or clarification let me know!</p> <p>Added combox fill method</p> <pre><code>try { List&lt;PreviousVersionData&gt; listID = PreviousVersionData.getDatabase(); if (listID != null) { foreach (PreviousVersionData l in listID) { cmboBoxPreviousVersion.Items.Add(string.Format("{0} - {1}", l.FormatID, l.FormatName)); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload