How to set an Infragistics ribbon group visiblity to false in code - vb.net

How to set an Infragistics ribbon group visiblity to false in code?
I am trying to hide an Infragistics group box depending on the users Dpi on form load.
There is a button inside the group area that I have managed to hide using:
utmApplicant.Tools("Match").SharedProps.Visible = False
I assumed I could use the same code to hide the group box but it keeps saying that the key has not been found but I am using the right key. Any suggestions?
I'm using VB.NET

It is not clear to what kind of object you are referring to.
In an Infragistics UltraToolbarsManager there is a Ribbon object that contains a Tabs collection. Each Tab contains a Groups collection and each Group contains one or more Tools.
So, to hide the first tab (I have used an integer to index, but the key string works as well)
utmApplicant.Ribbon.Tabs(0).Visible = False
To hide a specific group inside the first tab
utmApplicant.Ribbon.Tabs(0).Groups(0).Visible = False
To hide a particular tool assigned to a specific Group (a label, a button, a textbox or other kind of UI widgets) you could use this syntax
utmApplicant.Ribbon.Tabs(0)
.Groups(0)
.Tools("Match")
.InstanceProps.Visible = DefaultableBoolean.False
Tools are kept in the global collection under the UltraToolbarsManager hierarchy root but when assigned to a specific Group could be referenced with the syntax above.

Related

Conditional visibility on MS Access Form - how to write in VBA or Macro

I have some very (very) basic MS Access knowledge. I'm trying to expand a bit into either VBA or macros as I'd like to put in some conditional visibility for my form. Basically, I have a checkbox. If it's checked, I want three or four more fields to pop up. Someone was able to point me to a basic VBA formula of if (this checkbox) = true then, (fieldx).visible = true, else, (fieldx).visibility = false, end if.
But I'm so new to this that I need more help and explanation. I tried putting it in but couldn't get it to work (no error message, just nothing changed at all).
Specific questions:
-Does this formula seem right?
-If I want multiple fields to be visible, can I combine them into one formula or should I create a new "if" statement for all?
-Where do I enter this code? I'm running the Office 365 version. For all I know, I'm not even putting it in the right place.
-How do I determine the field names to replace the (this checkbox) and (fieldx) in the formula? I tried entering the name I title the fields as, but with the spaces in the name I got an error message, and without the spaces nothing happened. Is there a specific naming convention to turn the field names into formula-appropriate titles? Is the name listed somewhere?
-Once I get the formula entered, is there something I have to do to get it to run/take effect? I tried saving, closing and reopening with no changes.
-Is this the best way to go about this?
If there's anything else you think I should know, I would love to hear it - but please keep in mind I'm very new to this so if you could keep it at "dummy" or ELI5 levels of explanation, I'd appreciate it!
after creating a form with 4 textboxes and a checkbox put the form in design mode (lower right corner has design mode selected, select a textbox and hit property sheet on the ribbon (or f4).
On the property sheet note the visible property. set the visible property to false. Now the textbox will be invisible when the form starts.
Tip you can select all the textboxes at the same time and set their properties all at once.
Every control on the form and even the various parts of the form have properties you can set and play with. For instance you can give any name you want to any control. On the property sheet go to the other tab and set the name property.
Tip: choose a name you you will remember without having to look it up and describes the controls function.
Next select the checkbox (not the checkbox's label). On the property sheet go to the event tab and select the on click event. hit the ellipsis and choose code builder. Access is Event Driven. We want the textboxes to appear when the checkbox is selected so we put that code in the checkbox click event.
after choosing code builder we get the code window where we can browse among all the events for all our forms. for now all you should see is something like:
Private Sub mycheckbox_Click()
End Sub
So insert some code to handle the checkboxes like:
Private Sub mycheckbox_Click()
If mycheckbox = True Then
txtbox1.Visible = True
txtbox2.Visible = True
txtbox3.Visible = True
txtbox4.Visible = True
Else
txtbox1.Visible = False
txtbox2.Visible = False
txtbox3.Visible = False
txtbox4.Visible = False
End If
End Sub
now when the checkbox is not checked no textboxes are visible.
but when the checkbox is checked they appear

VB - Reference Control via a string stored in My.Settings

I'm making an extremely simple app which has multiple screens (as Panels) that are hidden/shown clicking buttons on a left sidebar.
I have a PNLHome, PNLServerSettings, PNLScripts, and PNLSettings as the main panels.
Each of the Panels .Name properties are "PNLHome", "PNLServerSettings", ....etc.
I want to be able to change the "Start Up Screen" based on the selection you make in a ComboBox in PNLSettings, so when you launch the app, the Panel that is immediately showing is based on that ComboBox selection.
I have the ComboBox items in place and I have a function that hides all panels and shows the one you pass into it:
showPanel(PNLHome) for example which will essentially just show the Panel you give it, all this is working fine. This showPanel() is triggered upon clicking one of the main buttons on the left sidebar
What I want is to pass a Control.Name string into my showPanel() func, then I want to store this .Name string into My.Settings via a "Save/Apply" button in the Settings Panel which I can set up easily.
Since I will be passing the .Name String into my showPanel() function, I need to be able to reference the Panel I'm showing by it's name rather than the Object ID itself (I'm not sure if it's called an ID but it's the 'name' declaring the Panel via a "DIM WithEvents PNLHome As Panel" declaration.
To summarize the question; Can I reference the PNLHome by its .Name Property?
Otherwise can I store the ID of PNLHome directly in My.Settings instead? I could easily pass My.Settings.StartPanel into my showPanel() func.
Just use the Controls collection to find the control.
Private Function GetPanel(PanelName As String) As Panel
Dim SomePanel As Panel = CType(Controls(PanelName), Panel)
Return SomePanel
End Function

Error: "The item with the specified name wasn't found."

I've been looking for this problem, but cannot find a solution that works for me.
I've made option buttons through the UI of word 2013 , and gave them a specified name in their properties ( "knop11" )
ThisDocument.Shapes("knop11").Visible = False
The above line is what I try to use to hide my option button when pressing a command button.
After making a new option button ( with default name "OptionButton1 ) it still doesn't work if I apply it to that button.
It depends on the type of control you are inserting, if you are using a ActiveX option button, it is not included within the shapes, but it will be created as an independent object. In such case you just have to use its functions directly.
However there is no 'visibility' property within option buttons, you might use a harsh work around like changing the buttons size or its forecolor. Something like:
If knop11.Height > 1 Then
knop11.Height = 1
Else
knop11.Height = 20
End If
Just as a quick tip, when you make the UI, the controls that are included within the shapes of the document are the ContentControls, and normally you fill the TAG property to look for them later. You might as well use the check box content control, and programming the option behaviour within your macros.

Word - how to uncheck checkboxes?

I have 4 checkboxes but we need to restrict selection to just a single one, meaning if you check the first, the other 3 will go unchecked. I know we could use ActiveX radio buttons but we'd prefer to avoid ActiveX if possible, plus with check boxes we have more control over the layout.
I've set the name of the checkbox appropriately to Check1:
And then I've put this very basic script into the Visual Basic section:
Private Sub Check1_Click()
Check1.Enabled = True
Check2.Enabled = False
Check3.Enabled = False
Check4.Enabled = False
End Sub
But unfortunately checking the first box doesn't uncheck the next 3.
Any ideas please? Thank you!
If these are Content Controls, as you indicate, then they do not have a CLICK event. Nor can they be identified by VBA by their Title property. The code you show us is for ActiveX controls, which you say you don't want to use...
Working with content control events is not as simple and intuitive as with ActiveX controls. Similar to form fields, Content Controls only have "editing" events that trigger on the user entering and exiting the content control. These events are available in the ThisDocument module, in the Document category.
The same ContentControlOnExit event triggers for ALL content controls in the document, so you need a Select Case or If conditional to query the ContentControl argument in order to know which content control was exited.
In order to address the other checkboxes you need to use the Document.SelectContentControlsByTitle (or ...ByTag) method which returns an array of all content controls with that title (or tag).
If you really want to emulate a "click" event then you need to insert a Custom XML Part in the document with nodes linked to the content controls. When the user changes the state of the control the ContentControlBeforeStoreUpdate event will trigger, letting you take action.
The property you need is Value, not Enabled.
The purpose of property Enabled is to prevent a control from being changed by user.
Additionaly, you need to prevent it from the events cascade. It means that when you change programatically the value of Check2, this will trigger Private Sub Check2_Click() and so on.
In order to make it work you should change your code like that:
Private Sub Check1_Click()
If Check1.Value Then
Check1.Value = True
Check2.Value = False
Check3.Value = False
Check4.Value = False
End If
End Sub
and similarly for the other check boxes.
For your purpose radio buttons will be better choice. Radio buttons have built-in functionality to uncheck currently selected button if other one is checked.

Run through all the controls in a form

I have a form and I am running through all the controls in that form.
My code is OK and is get all the controls with all their properties.
So for example I have a TabControl with 2 TabPages and 2 textboxes in each tabPage.
The problem is that for the tabPage that isn't selected , the textboxes' property visible is False, although I have set it to True.
I tried to solve this problem with Control.Select and Control.Focus , but Visible is still False:
Private Sub createXML(ByVal cnt As Control, ByVal elem As XElement)
Try
cnt.Select()
cnt.Focus()
Select Case cnt.Controls.Count
Case Is = 0
'Code here to write XElement to an XDocument
'Check Controls properties
Case Is > 0
For Each childCnt As Control In cnt.Controls
childCnt.Select()
childCnt.Focus()
Dim childElem As New XElement(childCnt.GetType.ToString)
Select Case childCnt.Controls.Count
Case Is = 0
'Code here to write XElement to an XDocument
'Check Controls properties
Case Is > 0
createXML(childCnt, childElem)
End Select
Next
End Select
Any ideas?
Note that I don't know what controls I have to run through each time
Your problem in this case is that a TabControl sets everything to invisble unless they are present in the currently selected tabpage. And when you change tab the controls are set to visible and previous ones dissapeares. So how does the tabcontrol keep track of a control that is manually set to visible false, so that it doesn't light up when the tab is changed? Well the visible property is not really based on a boolean value. It's merely an easy way to interpret it for us programmers. Either you see it or you don't, no rules to keep in mind or settings to mess up. Visible or not simple as that.
So what to do with your issue. Basically, my first thought when I see this is that you want to create a "open the program so it looks the same as when it was closed"-function. Which of course is not working properly at the moment since your parser probably set everything to visible=false, which at previously stated means not visible ever. Hence not showing after Tab control page change when loaded.
So solutions:
1. Add a tag to the controls in the tab control. This way you can look for the tag when saving. If it's there, set the visible property to true. (Easy to understand for you when maintaining in the future)
2. Use reflection to get the actual visible state. Look at SO thread and read about reflection: Using control.Visible returns False if it's on a tab page that is not selected (Not so easy to understand when maintaining in future)