Remove bold formatting from copied DataGridView column headers

When copying from DataGridView and pasting to Excel, the column headers were bolded. This was undesirable, requiring a manual Paste Special… as Text or Unicode Text every time data was copied. This problem was resolved by adjusting the clipped data’s format. Use TextDataFormat.UnicodeText to retain the row/column structure. If TextDataFormat.CommaSeparatedValues is used then the data pastes into one Excel column.
 

private void btnClipGrid_Click(object sender, EventArgs e)
{
// Save entire DataGridView to clipboard.
dgvMesInfo.SelectAll();
Clipboard.SetDataObject(dgvMesInfo.GetClipboardContent());
Erectile Dysfunction is often caused by stressful conditions such as fatigue, stomach upset, indigestion, restricted blood supply to the penile sildenafil generic viagra organ is insufficient because of arterial clogging. VigaPlus is the plant based version of the get viagra in canada without doctor prescription. They are enriched with vitamins and minerals generic cialis in australia that aid your digestive system. Occasionally the veins evade holding blood after an appropriate blood discount viagra sales supply. dgvMesInfo.ClearSelection();
// Reformat clipboard into Text (tab-separated). // Why not use vanilla DGV data? Upon pasting vanilla DGV data into Excel, column headers are bolded.
string tabText = Clipboard.GetText(TextDataFormat.UnicodeText);
Clipboard.Clear();
Clipboard.SetText(tabText);
}

This entry was posted in C#, Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.