You can always try to set DataPropertyName properties of particular columns to match what's in your DataTable. Then bind that DataTable to a BindingSource and bind that binging source to your grid.
As long as names of columns in your DataTable match DataPropertyNames of your DataGrid columns, your data grid should display only those matched columns.
In my example my stred proc does something simle like:
ALTER PROCEDURE ps_Clients_Get
AS
BEGIN
SELECT
convert(varchar(2000), path) as [Client Folder],
c.description as [Client Name],
c.*
FROM Client c
END
GO
and my C# code:
using (DataTable dt = new DataTable())
{
using (OdbcConnection cnDsn = new OdbcConnection(cmLocalTrackingDBDSNAME))
{
cnDsn.Open();
using (OdbcCommand cmdDSN = new OdbcCommand())
{
var _with1 = cmdDSN;
_with1.Connection = cnDsn;
_with1.CommandType = System.Data.CommandType.StoredProcedure;
_with1.CommandText = "{ CALL ps_Clients_Get }";
using (OdbcDataAdapter adapter = new OdbcDataAdapter())
{
dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
adapter.SelectCommand = cmdDSN;
adapter.Fill(dt);
bindingSourceDataLocation.DataSource = dt;
dataGridViewDataLocation.AutoGenerateColumns = false;
dataGridViewDataLocation.DataSource = bindingSourceDataLocation;
}
}
cnDsn.Close();
}
}
Good luck!