We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TabPageAdv v.3.2.1.0

Thread ID:

Created:

Updated:

Platform:

Replies:

61371 May 24,2007 05:48 AM Jun 5,2007 04:07 AM Windows Forms 10
loading
Tags: Tools
Lawrence Graham
Asked On May 24, 2007 05:48 AM

I have written a custom renderer for a TabControlAdv (which I must say, in itself, is a poor implementation (this should be something at the tab page level)). The renderer among other things changes the width of the tab page border. Now however, I cannot find out how to ensure that the TabControl scroll bars are displayed and enabled correctly. The TabControl remains convinved that the TabPages have a different length, based on the text length and not on the actual tabpage border size. Any ideas?

Golda Rebecal [Syncfusion]
Replied On May 24, 2007 10:36 AM

Hi Bert, I am afraid that I am not able to understand your requirement clearly. I have attached a sample that uses a custom renderer for TabControlAdv. Could you please modify the sample so that the issue could be seen clearly? Also please give me more information regarding this issue. This will help us to resolve the issue soon. We appreciate your interest in Syncfusion products. http://websamples.syncfusion.com/samples/Tools.Windows/F61371/Main.htm Best regards, Golda

Lawrence Graham
Replied On May 29, 2007 06:25 AM

Hi Golda

I want to write a custom renderer that allows me to dynamically change the width of the tab label. This is done based on the length of the text provided by an interface that the first child control in the tabpage implements (see code). The problem is, is that the tabcontrol does not recognize the resized tab sizes as calculated by GetCurrentBounds and simply uses the original sizes (based on the tab page text). For these reason cannot get the scroll bars to work at all.

Note, I do not want to just change the tab page text, but must do it with a renderer.


public class TabPageCountRenderer : TabRenderer2D
{
private TabControlAdv m_tabControlAdv = null;
private TabPageAdv m_tabPage = null;
private int m_localDeltaX = 0;
private int m_index = -1;
private int m_count = 0;
private int m_countPrevious = 0;
private Font m_fontInvalid = null;
private bool m_active = false;
private static TabPageCountPanelProperty tabPropertyExtender = null;

static TabPageCountRenderer()
{
tabPropertyExtender = new TabPageCountPanelProperty();
TabRendererFactory.RegisterTabType(TabStyleName, typeof(TabPageCountRenderer), new TabPageCountPanelProperty());
}

public static new TabPageCountPanelProperty TabPanelPropertyExtender
{
get { return tabPropertyExtender; }
}


public TabPageCountRenderer(ITabControl parent, ITabPanelRenderer panelRenderer)
: base(parent, panelRenderer)
{
m_tabControlAdv = parent.GetControl() as TabControlAdv;

if (m_tabControlAdv != null)
{
m_tabControlAdv.SelectedIndexChanged += new EventHandler(m_tabControlAdv_SelectedIndexChanged);
m_tabControlAdv.Disposed += new EventHandler(m_tabControlAdv_Disposed);
m_fontInvalid = new Font(m_tabControlAdv.Font, FontStyle.Bold);

}
}

public int Index
{
get { return m_index; }
}

public int GetDeltaX()
{
int deltaX = 0;
foreach(ITabRenderer renderer in m_tabControlAdv.Renderer.Renderers)
{
TabPageCountRenderer countRenderer = renderer as TabPageCountRenderer;
if(countRenderer != null)
{
if (countRenderer.Index < m_index)
{
deltaX += Rectangle.Round(countRenderer.GetCurrentBounds()).Width;
}
}
}

return deltaX;
}

public static new string TabStyleName
{
get { return "TabPageCountRenderer"; }
}

protected override void DrawText(Graphics g, RectangleF rectText, string text, StringFormat format, DrawTabEventArgs e)
{
if (m_active)
{
//Draw the tab text, depending on the selected state

if (m_tabControlAdv.SelectedIndex != m_index && m_countPrevious != m_count)
{
e.Font = m_fontInvalid;
}
else if (m_tabControlAdv.SelectedIndex == m_index)
{
e.Font = m_tabControlAdv.Font;
m_countPrevious = m_count;
}

rectText = RectangleF.FromLTRB(
rectText.Left - m_localDeltaX / 2,
rectText.Top,
rectText.Right + m_localDeltaX / 2,
rectText.Bottom);

text = string.Format("{0} ({1})", m_tabPage.Text, m_count);
}

base.DrawText(g, rectText, text, format, e);
}

void m_tabControlAdv_SelectedIndexChanged(object sender, EventArgs e)
{
if (m_tabControlAdv.SelectedIndex == m_index)
{
m_countPrevious = m_count;
}
}



public override RectangleF GetCurrentBounds()
{
RectangleF currentBounds = base.GetCurrentBounds();
int leftOffset = GetDeltaX();

currentBounds = RectangleF.FromLTRB(
leftOffset,
currentBounds.Top,
leftOffset + currentBounds.Width + m_localDeltaX,
currentBounds.Bottom);


return currentBounds;
}

public override ITabData TabData
{
get
{
return base.TabData;
}
set
{
//For a given renderer, the tabdata can be set multiple times

m_active = false;
base.TabData = value;
if (m_tabControlAdv != null && value != null)
{
foreach (TabPageAdv tabPage in m_tabControlAdv.TabPages)
{
if (tabPage.Text == value.Text)
{
m_tabPage = tabPage;
m_index = tabPage.TabIndex;
tabPage.TabIndexChanged -= new EventHandler(tabPage_TabIndexChanged);
tabPage.TabIndexChanged += new EventHandler(tabPage_TabIndexChanged);



if (tabPage.Controls.Count > 0 && tabPage.Controls[0] is ICountProvider)
{
((ICountProvider)tabPage.Controls[0]).CountChanged += new CountChangedHandler(TabPageCustomRenderer_CountChanged);

using (Graphics graphics = m_tabControlAdv.CreateGraphics())
{
m_localDeltaX = Size.Round(graphics.MeasureString("########", m_tabControlAdv.Font)).Width;
}

m_active = true;
}

break;
}
}
}
}
}

void m_tabControlAdv_Disposed(object sender, EventArgs e)
{
if (m_fontInvalid != null)
{
m_fontInvalid.Dispose();
}
}

void TabPageCustomRenderer_CountChanged(object sender, CountChangedEventArgs e)
{
m_count = e.Count;
Rectangle invalid = Rectangle.Round(base.GetRedrawBounds());
m_tabControlAdv.Invalidate(invalid, false);
}

void tabPage_TabIndexChanged(object sender, EventArgs e)
{
m_index = m_tabControlAdv.TabPages.IndexOf(m_tabPage);

}
}


>Hi Bert,
>
>I am afraid that I am not able to understand your requirement clearly. I have attached a sample that uses a custom renderer for TabControlAdv. Could you please modify the sample so that the issue could be seen clearly? Also please give me more information regarding this issue. This will help us to resolve the issue soon.
>
>We appreciate your interest in Syncfusion products.
>
>http://websamples.syncfusion.com/samples/Tools.Windows/F61371/Main.htm
>
>Best regards,
>Golda

Murugan [Syncfusion]
Replied On May 29, 2007 02:58 PM

Hi Bert,

To show scroll bar, please set ShowScroll and SizeMode property of the TabControlAdv Control.

[Code]
this.tabControlAdv1.SizeMode = Sycfusion.Windows.Forms.Tools.TabSizeMode.Normal;
this.tabControlAdv1.ShowScroll = true;

I could not add your renderer class. It throws some error. If the above code snippet fails, could you please send us the sample? This could help us to analyze furhter.

Thanks,
Murugan P.S


Lawrence Graham
Replied On May 31, 2007 04:47 AM

I have attached the test project that I wrote to test the custom renderer. The idea is that the renderer will check the first control in the tab page and if it implements the ICountProvider interface it will register for notifications related to changes in the count (for example number of rows in a grid) of the control in the tab page. The count is then shown as a formatted string in the tab page text. This all works really well. As you will see however, the tab cotnrol scroll bars are not activated correctly. They are only enabled when the form is much smaller than the combined widths of all the tabs and when they are enabled they do not scroll the tabs when pressed. It would appear that the tabcontrol does not use the GetCurrentBounds of the renderer to determine the width of the tabs and therefore when to enable or even make the scroll buttons work.


>Hi Bert,

To show scroll bar, please set ShowScroll and SizeMode property of the TabControlAdv Control.

[Code]
this.tabControlAdv1.SizeMode = Sycfusion.Windows.Forms.Tools.TabSizeMode.Normal;
this.tabControlAdv1.ShowScroll = true;

I could not add your renderer class. It throws some error. If the above code snippet fails, could you please send us the sample? This could help us to analyze furhter.

Thanks,
Murugan P.S



app7.zip

Murugan [Syncfusion]
Replied On May 31, 2007 05:50 PM

Hi Bert,

The problem occurs when we calculating currentBounds in the GetCurrentBounds() method. Herewith I have attached the modified sample. Please refer to this and let me know if it helps you.

[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61371_1/Main.htm

Thanks,
Murugan P.S

Lawrence Graham
Replied On June 1, 2007 06:28 AM

Hi

Thanks for your reply. I tried your code sample, and yes the scroll bars work, but the rendering of the tab is now incorrect. Please see attachment. Can you otherwise help me find a fix?

Thanks


>Hi Bert,

The problem occurs when we calculating currentBounds in the GetCurrentBounds() method. Herewith I have attached the modified sample. Please refer to this and let me know if it helps you.

[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61371_1/Main.htm

Thanks,
Murugan P.S


untitled41.zip

Golda Rebecal [Syncfusion]
Replied On June 2, 2007 07:16 AM

Hi Bert,

I am able to see the issue of tabs not being correctly rendered in v3.2.1.0 when the GetCurrentBounds() method is modified in your sample.

I tested the same sample using the latest version(5.1.0.51) and I found that the issue is not there. I have attached a screenshot that shows what I could see at my end.

Could you please consider upgrading to the latest version?

You can download the latest version from the below link:
-----------------------------------------------------
http://www.syncfusion.com/downloads/latestversion/default.aspx

Unlock key:
-----------

If you hold a Syncfusion license with a valid subscription, you can obtain your key for this version by visiting the "Download the latest versions" section within Direct-Trac and clicking on the appropriate key icon. If you''''re currently evaluating our products or considering renewing an expired subscription, please write to salessupport@syncfusion.com to request a key.

Kindly let me know if this helps you.

http://websamples.syncfusion.com/samples/Tools.Windows/F61371_1/Main.htm

Best regards,
Golda

Lawrence Graham
Replied On June 4, 2007 04:06 AM

I am not able to upgrade. Is it not possible for you to replicate this with v.3.2.1.0? Otherwise I will have to revert to the standard Microsoft controls.

Thanks

>Hi Bert,

I am able to see the issue of tabs not being correctly rendered in v3.2.1.0 when the GetCurrentBounds() method is modified in your sample.

I tested the same sample using the latest version(5.1.0.51) and I found that the issue is not there. I have attached a screenshot that shows what I could see at my end.

Could you please consider upgrading to the latest version?

You can download the latest version from the below link:
-----------------------------------------------------
http://www.syncfusion.com/downloads/latestversion/default.aspx

Unlock key:
-----------

If you hold a Syncfusion license with a valid subscription, you can obtain your key for this version by visiting the "Download the latest versions" section within Direct-Trac and clicking on the appropriate key icon. If you''re currently evaluating our products or considering renewing an expired subscription, please write to salessupport@syncfusion.com to request a key.

Kindly let me know if this helps you.

http://websamples.syncfusion.com/samples/Tools.Windows/F61371_1/Main.htm

Best regards,
Golda

Golda Rebecal [Syncfusion]
Replied On June 4, 2007 09:58 AM

Hi Bert,

I analyzed the source code and found that there has been a lot of API changes in latest versions when compared with version 3.2.1.0. Hence it is not possible to incorporate all these in v3.2.1.0.

Please let me know if you have any other questions.

Best regards,
Golda

Lawrence Graham
Replied On June 5, 2007 04:07 AM

Thanks for looking.

I will go back to using the Microsoft default controls.

>Hi Bert,

I analyzed the source code and found that there has been a lot of API changes in latest versions when compared with version 3.2.1.0. Hence it is not possible to incorporate all these in v3.2.1.0.

Please let me know if you have any other questions.

Best regards,
Golda

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;