質問

I made a function like this:

public DataTable getMtrBcdMod()
{
    DataSet ds = new DataSet();
    string query = "select pMtrBcdMod, sMtrBcdMod from dtMtrBcdMod ";

    SqlCommand cmd = new SqlCommand(query, DatabaseConnection);
    SqlDataAdapter dap = new SqlDataAdapter();
    dap.SelectCommand = cmd;
    dap.Fill(ds);

    return ds.Tables[0];
}

and I wish designtime, editing a datagridview, add a DataGridViewComboBoxColumn that points at the datasource the DataTable returned by the function, using ValueMember pMtrBcdMod and sMtrBcdMod as DisplayMember..

how can I do this?

thanks

役に立ちましたか?

解決

You need to attach the combobox to a column in your DataTable by assigning the DataPropertyName of your custom combo box to the chosen column, ie, "Column A".

You then hide the original column from display, but all changes that are made in your combobox will be reflected in the underlying datatable column also.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top