Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to enable / disable toggle box in dialog

Status
Not open for further replies.

fatdogs81

Mechanical
Joined
Sep 22, 2014
Messages
22
Location
KR
I'm using nx7.5, C#(.NET Framework 3.5)

I made 2 toggle boxes with by below code.

toggle0 = (NXOpen.BlockStyler.UIBlock)theDialog.TopBlock.FindBlock("toggle0");
toggle1 = (NXOpen.BlockStyler.UIBlock)theDialog.TopBlock.FindBlock("toggle0");

I want... if toggle0 is checked, then toggle1 is disabled.

Please let me know what code should be inserted.

Below is update callback in my code.

public int update_cb(NXOpen.BlockStyler.UIBlock block)
{

try
{
if (block == toggle0)
{
[Disable toggle1 code here]
}

if (block == toggle1)
{

}

}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}



Thanks in advance for your help.
 
Off the top of my head it's going to be something like:
Code:
toggle1.setEnable(!toggle0.value());

Graham Inchley, Systems Developer.
NX6, NX8.5(testing)
 
grinch33, thank you for your reply.

Unfortunately, setEnable method is not containe in NXOpen.BlockStyler.UIBlock.

I wonder what method can I use?

please help me more.
 
Oops, I didn't take note of the NX version you are using, sorry. The suggested code would work at NX8.5.
For NX7.5 you need to do something more like this:
Code:
// Get the value of toggle0 (whether it is checked or not)
PropertyList pl0 = toggle0.getProperties();
boolean val = pl0.getLogical("Value");
pl0.dispose();

// Set the enabled state of toggle1 depending on toggle0's checked value
PropertyList pl1 = toggle1.getProperties();
pl1.setLogical("Enable",!val);
pl1.dispose();
As you can see at NX7.5 and earlier you have to ask for a PropertyList object from the UIBlock and get/set the properties by name from there.
At NX8 (or 8.5 I can't recall) the way you access properties on blocks changed. Since then there are separate classes for each block type and these classes have specific methods to access the properties. This is much more robust and concise.

Graham Inchley, Systems Developer.
NX6, NX8.5(testing)
 
Very thank you sir!

I solved with your advice.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top