I am trying to fill my DGV from DB, but one of the columns contains a row that is too long and therefore the cells are empty. I would just like to truncate the string, but the methods that are lower in the code do not work. How to be? On the screen the problem itself.
string nameConn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; string search = "SELECT * myTableName"; using (SqlConnection con = new SqlConnection(nameConn)) { using (SqlCommand comm = new SqlCommand(search, con)) { comm.CommandType = CommandType.Text; using (SqlDataAdapter sda = new SqlDataAdapter(comm)) { using (DataTable data = new DataTable()) { try { sda.Fill(data); } catch (Exception exc) { MessageBox.Show(exc.Message); } dataGridView5.DataSource = data; //CType(dataGridView5.Columns(4), DataGridViewTextBoxColumn).MaxInputLength = 5; //dataGridView5.Columns[4].MaxInputLength = 5; 
Trimmethod). - Alexander Petrov