Hi, folks. I'm retrieving data from a table with an adapter and using thesse data to populate a datagridview. It's working fine, but now I want to change the column header, but I don't know how. I found nothing here or in other foruns aboute this. Can any one help me?
The following code (simplified) is inside a routine that returns the table.
The above routine mounts the Select command.
In the main program there is:
The parameters in the routine calling indicate the columns and the commands used.
As I said, it works fine, but I need to change the column headers in the datagridview. I've tried many alternatives, but none has worked. How can I do this?
Thanks.
The following code (simplified) is inside a routine that returns the table.
C#:
var con = new SqlConnection(ConfigurationManager.AppSettings["TextoConexao"]);
SqlCommand Cmd = new SqlCommand(TextoSLQ, con);
DataTable Tab1 = new DataTable();
SqlDataAdapter ad = new SqlDataAdapter();
Cmd.CommandType = CommandType.Text;
ad.SelectCommand = Cmd;
ad.Fill(Tab1);
return Tab1;
In the main program there is:
C#:
dataGridView1.DataSource = tb.LeTabelaComplexa(Campos, " from ITEM T1 ", "", " order by T1.ITEM_TX_NOME");
As I said, it works fine, but I need to change the column headers in the datagridview. I've tried many alternatives, but none has worked. How can I do this?
Thanks.
Last edited by a moderator: