13

Selected item in Datagridview to display in ComboBox

 3 years ago
source link: https://www.codesd.com/item/selected-item-in-datagridview-to-display-in-combobox.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Selected item in Datagridview to display in ComboBox

advertisements

I am trying to get a selected item from datagridview to show in a combobox.

I have done

ComboBox1.Text = DataGridView1.CurrentCell.Value

However, I need it to display two fields in the combobox from the datagrid. Is there a way to do the above with a SQL query? Because I need to concat a query to display in the combobox because right now it's only displaying one field that I need. Thank you :-)


You could try doing something like this.

        ComboBox1.Text = DataGridView1.SelectedRows.Item(0).Cells(0).FormattedValue + " " + DataGridView1.SelectedRows.Item(0).Cells(1).FormattedValue

        ComboBox1.Text = DataGridView1.SelectedRows.Item(0).Cells(0).FormattedValue + " " + _
                         DataGridView1.SelectedRows.Item(0).Cells(1).FormattedValue

However if your drop down list box has an ID in the value you and you have it in the Grid, you set the

ComboBox1.Value = DataGridView1.Rows[DataGridView1.SelectedIndex].Cells["HiddenIdRow"].Text.ToString()




About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK