Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

How to enable / disable toggle box in dialog

Status
Not open for further replies.

fatdogs81

Mechanical
Sep 22, 2014
22
0
0
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.
 
Replies continue below

Recommended for you

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)
 
Status
Not open for further replies.
Back
Top