Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I set the Properties of a DataGridViewComboBoxColumn in a thread? (C# Winforms)
    primarykey
    data
    text
    <p>I'm studying delegates and simple threading, I tried it in a <code>ComboBox</code> control, and experimented in a <code>DataGridViewComboBoxColumn</code> (cause I thought it would be the same) but it seems there's no <code>Invoke</code> property for this kind.</p> <p><strong>How can I set DataGridViewComboBoxColumn properties in a thread?</strong><br> Please see my code, this works for setting the properties of a <code>ComboBox</code> control using a thread: </p> <pre><code> private delegate void DelegateSetProperties(DataTable dataSource, string valueMember, string displayMember); Thread thread1; DelegateSetProperties delegateSetProperties; private void Form1_Load(object sender, EventArgs e) { delegateSetProperties = new DelegateSetProperties(SetProperties); thread1 = new Thread(new ThreadStart(InitValues)); thread1.IsBackground = true; thread1.Start(); } private void SetProperties(DataTable dataSource, string valueMember, string displayMember) { comboBox1.DataSource = dataSource; comboBox1.ValueMember = valueMember; comboBox1.DisplayMember = displayMember; comboBox1.SelectedIndex = 0; //dataGridViewComboBoxColumn1.DataSource = dataSource; //dataGridViewComboBoxColumn1.DisplayMember = valueMember; //dataGridViewComboBoxColumn1.ValueMember = displayMember"; } void InitValues() { var dt = new DataTable { TableName = "CATEGORY", Columns = { {"CategoryCode", typeof(string)}, {"Name", typeof(string)}, } }; dt.Rows.Add("C1", "Category1"); dt.Rows.Add("C2", "Category2"); dt.Rows.Add("C3", "Category3"); // and so on... comboBox1.Invoke(delegateSetProperties, new object[] { dt, "CategoryCode", "Name" //dataGridViewComboBoxColumn1.Invoke(delegateSetEvents, new object[] { dt, "CategoryCode", "Name" }); }); } </code></pre> <p>Please help...thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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