2

I have a simple tabbed web browser I'm working on using Visual C#. I'm working on the tabs part, and I wanted each tab to be a fixed width. The problem is, when it's set to sizemode fixed, the text from the web page's titles are aligned wrong. It's as if the text starts from the center, and goes toward the right, leaving a huge open space on the left hand side. I've tried finding this error, but google just leaves me dry. Here's a screenshot: https://i.stack.imgur.com/JTKwa.png

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Andrew S.
  • 21
  • 1
  • 2
  • 2
    Please post your code kind sir! – FlyingStreudel Jun 20 '11 at 18:54
  • There's not much code. I used the side panel in Visual C# to change the sizeMode from 'Normal' to 'Fixed' then set the fixed width and height to '100' and '20'. Here's the block of code that places the titles in the tabs though. `private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { tabPage1.Text = webBrowser1.Document.Title.ToString(); }` – Andrew S. Jun 20 '11 at 19:32
  • I thought tab content was called a header? Or is this WinForms? – FlyingStreudel Jun 20 '11 at 19:37

1 Answers1

2

From MSDN

Changing the Text property value does not automatically center the new value on the tab if the TabControl has a SizeMode property value of Fixed. You can work around this limitation by setting the TabControl.ItemSize property or by removing the TabPage from the TabControl.TabPages collection and adding it back to the collection. Both of these actions will automatically center the text.

FlyingStreudel
  • 4,434
  • 4
  • 33
  • 55