
VISUAL STUDIO CHANGE SELECTED TEXT COLOR CODE
To copy color syntax highlighted code into Word, copy your selected code from VS Code and paste it into Word. We’ll see this in action with various applications and provide some additional steps to maximize the beauty of your syntax highlighted code. How is this accomplished? It’s very simple! When you are in VS Code copy your selected code to the clipboard, VS Code brings the color syntax formatting along for the ride so the formatted text can be pasted into applications such as Word and Gmail. This will prove useful whether you are using JavaScript, JSON, HTML, CSS, TypeScript, Markdown, C++, Java, PHP, Python, Go, T-SQL, XML, C# or a host of other languages and data formats that Visual Studio Code supports.

VISUAL STUDIO CHANGE SELECTED TEXT COLOR HOW TO
Anything else looks ungainly.In this article, we learn how to copy from Visual Studio Code with color syntax highlighting to various other applications including Word, PowerPoint, Outlook, OneNote, and Gmail to achieve beautiful, clear code samples for documentation, presentations, and general communication. You can experiment with different colors and sizes, but I found that a size 10 font is probably as big as you’ll want to go. The selected tab header really stands out now. Running the application now brings the following result: And in place of the default Text size of the TabPage header Text (which is 8.25), I’ve hard-coded a new value of 10. The only changes are in line 21 where I’ve now created a Font that I’ve named BiggerBoldFont to replace the original BoldFont. ' Paint the Text using the appropriate Bold and Color settings If Convert.ToBoolean(e.State And DrawItemState.Selected) Then Dim BiggerBoldFont As New Font(, 10, FontStyle.Bold)Į.Graphics.DrawString(SelectedTab.Text, BiggerBoldFont, RedTextBrush, HeaderRect, sf) And in line 24, I use the BlackTextBrush to paint Text on all other TabPage headers.įinally in line 28-29 I also Dispose of the RedTextBrush, as well as the renamed Black one. Then in line 21, I use the RedTextBrush to paint the Text for the selected TabPage header. (For additional clarity, I also changed the name of the Brush in Line 10 to BlackTextBrush. In Line 11, I added a second Brush named RedTextBrush, this time one that holds the color Red. You’ll see that the changes I’ve made are as follows: ' Paint the Text using the appropriate Bold and Color setting If Convert.ToBoolean(e.State And DrawItemState.Selected) Then Dim BoldFont As New Font(,, FontStyle.Bold)Į.Graphics.DrawString(SelectedTab.Text, BoldFont, RedTextBrush, HeaderRect, sf)Į.Graphics.DrawString(SelectedTab.Text, e.Font, BlackTextBrush, HeaderRect, sf) ' Create two Brushes to paint the Text Dim BlackTextBrush As New SolidBrush(Color.Black)ĭim RedTextBrush As New SolidBrush(Color.Red)

Here’s the code I’m using to change the Text color of a selected tab to Red:

' Paint the Text using the appropriate Bold setting If Convert.ToBoolean(e.State And DrawItemState.Selected) Then Dim BoldFont As New Font(,, FontStyle.Bold)Į.Graphics.DrawString(SelectedTab.Text, BoldFont, TextBrush, HeaderRect, sf)Į.Graphics.DrawString(SelectedTab.Text, e.Font, TextBrush, HeaderRect, sf)Įnd If ' Job done - dispose of the Brushes Sf.LineAlignment = StringAlignment.Center

' Set the Alignment of the Text Dim sf As New StringFormat() ' Create a Brush to paint the Text Dim TextBrush As New SolidBrush(Color.Black) ' Get the area of the header of this TabPage Dim HeaderRect As Rectangle = TabControl1.GetTabRect(e.Index) ' Identify which TabPage is currently selected Dim SelectedTab As TabPage = TabControl1.TabPages(e.Index) Private Sub TabControl_DrawItem(sender As Object, e As ) Handles TabControl1.DrawItem
