Orange, could you explain your situation better?
So I understand, you have a single-screen application and in this there are TextBox and ComboBox fields, and you need to create a query of the bank query with those fields, when those fields are filled,
If so, a simple idea.
Use an if to identify which Text or Combo has been filled or selected and fill in the TAG of the fields with the name of the columns of the table.
Ex:
private void DefineNomeCampos()
{
comboBox1.Tag = "COL_TIPOPESSOA";
textBox1.Tag = "COL_NOMEPESSOA";
}
private void PreencheQuery()
{
StringBuilder sbSelect = new StringBuilder();
StringBuilder sbWhere = new StringBuilder();
sbSelect.Append("Select ");
if (!string.IsNullOrEmpty(textBox1.Text))
{
sbSelect.Append(textBox1.Tag + ",");
sbWhere.Append(textBox1.Tag + "=" + textBox1.Text + ",");
}
if (Convert.ToInt32(comboBox1.SelectedValue) != -1)
{
sbSelect.Append(comboBox1.Tag + ",");
sbSelect.Append(comboBox1.Tag + "," + comboBox1.SelectedText + "," );
}
}