Author Topic: ProductivityPack TabTools - samples  (Read 103 times)

Offline Misiu

  • Sr. Member
  • ****
  • Posts: 81
  • Karma: +0/-1
  • Gender: Male
    • View Profile
ProductivityPack TabTools - samples
« on: August 03, 2018, 03:37:33 AM »
In my environment, I'm using Pivotal Client 6.5.2 and Productivity Pack 4.2.
I'm trying to show/hide PivotalTabPage based on some conditions.

I've found this movie https://www.dailymotion.com/video/x1437wh showing Tab Tolls from ProductivityPack.
At 09:10 You can see that there is code that checks user group and conditionally calls Hide() on specific tab.

I've searched all over installers for code showing usage of that method, but I got nothing.

Do anyone have sample code showing usage of Productivity Pack from C#?
CRMCulture isn't existing anymore, so this forum is my only hope.

Any materials and samples are welcome :)

Offline MarcK4096

  • Jr. Member
  • **
  • Posts: 10
  • Karma: +1/-0
    • View Profile
Re: ProductivityPack TabTools - samples
« Reply #1 on: August 13, 2018, 10:11:56 AM »
The winforms tab control doesn't actually allow hiding of tabs.  The standard way to do this is to remove the tab from the control when you want to hide it and then add it back when you want to show it.

If you wanted to use the PP for this, you could try the following in your client task code:

var tabPage = new crmc.Foundation.TabPageLibrary("nameOfTab", (CdcSoftware.Pivotal.Engine.UI.Forms.PivotalClientFormControl)this.FormView.FormControl);
tabPage.Hide();

One challenge with the Pivotal SmartClient is that it likes to reuse forms as much as possible for performance reasons.  So, if you hide a tab, your code needs to be aware that the next time the form is initialized, the tab might already be gone.  I think one issue with this involves GetControlByName().  With the tab removed, I don't think the children can be found anymore.


Offline Misiu

  • Sr. Member
  • ****
  • Posts: 81
  • Karma: +0/-1
  • Gender: Male
    • View Profile
Re: ProductivityPack TabTools - samples
« Reply #2 on: August 17, 2018, 01:44:27 AM »
Hi MarcK4096,

thank You for reply.
I know that the only way to hide tab in winforms tab control is to remove that tab and add it again when I want to show it.
I've used PP as You showed.

In `OnFormInitialized` I'm creating reference to my tab page like this:

Code: [Select]
private TabPageLibrary _tpl;

public override void OnFormInitialized()
{
    base.OnFormInitialized();     
           
    if(_tpl == null)
        _tpl = new TabPageLibrary("MyTabPage", FormControl);

    ShowCorrectTabs();
}

private void ShowCorrectTabs()
{
    try
    {
        int productType = Convert.ToInt32(PrimaryDataRow[Common.Data.Client.Field.ProductType]);

        if (productType  == 0 && _tpl != null)
        {
            _tpl.Hide();
        }
        else if (productType == 1 && _tpl != null)
        {
            _tpl.Show();
        }
    }
    catch (Exception e)
    {
        Logger.LogException(e);
    }
}

I've got additional checks for _tpl != null to avoid any potential errors.

Hope this helps anyone :)

P.S.
Does anyone have any materials related to PP? Especially samples source code.