Sunday, 9 November 2014

Making of PacEdge Part 02

...continued from part 1

15The VB.Net code for the PacEdge program is available at the end of the last part and you can refer it while reading the posts.

For setting up a VB.Net Forms project, refer this tutorial.

The PacEdge project is a VB.Net Forms project. Of all the controls, TreeList resizes with the form, whereas all other controls remain fixed.

16

Below is a table of Anchor properties for the various controls.

Anchor

Controls

Top, Left

PacEdge from Assembly

Include Draft

PAR

PSM

Top, Bottom, Left, Right

TreeList

Bottom, Left

Specify PacEdge file

Create PacEdge

Password Check box

Password Text box

View Password

The buttons with images have their ImageAlign property set to MiddleCenter and TextImageRelation set to ImageBeforeText.

Both Size and Minimum Size for the dialog are (510, 540) while the StartupPosition is CenterScreen.

The center of attraction of the program is the TreeList control which can be viewed as a TreeView with multiple columns or a Collapsible ListBox. The control can be downloaded from this CodeProject.

Once you download the project and sample code, look for the file System.Windows.Forms.TreeListView.dll. I placed it in the bin folder of my project and to add the control to the toolbox and then to the form, follow these steps:

1. Scroll down to the bottom of the Toolbox and right-click in the empty area under General as shown and pick Choose Items... Alternatively you can select add Tab and then right click again for Choose Items...

2. Browse to the location where you placed the TreeListView.dll from step (1).

3. The control is added to the Toolbox and also the cursor changes so you can also place it immediately on the Form.

The TreeListView control in the PacEdge program has two top nodes: Solid Edge Files and Other Files.

18

The Solid Edge Files node has sub-nodes each for Assembly, Part, Sheetmetal and Draft files. The Other Files node does not have any sub-nodes. Files are directly added under it as seen in image above.

Form_Load: The Form’s Load event handles just two things:

  1. Create the root nodes for Solid Edge files and Other files. The nodeSE and nodeOther are of type TreeListViewItem. The lstFiles which is the TreeListView control is then set to Expand All nodes.
  2. Checks the Checked value for the PasswordView check box and accordingly sets the PasswordChar property to an empty string or a special character. Typical characters used are a Star (*) or a Hash (#).

 19 Tip: To use other characters like a Dot (•), type Alt+0149 quickly from the numeric keypad.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error Resume Next

        nodeSE = lstFiles.Items.Add("Solid Edge Files", 0)
        nodeOther = lstFiles.Items.Add("Other Files", 1)

        lstFiles.ExpandAll()

        If chkPasswordView.Checked = True Then
            txtPassword.PasswordChar = String.Empty
        ElseIf chkPasswordView.Checked = False Then
            txtPassword.PasswordChar = "#" ' or # or o or •
        End If
    End Sub

When the PasswordChar property is set to String.Empty or just “” the password typed in the TextBox is revealed. When it is set to any other character, the password is ‘masked’, meaning the actual word typed in is still stored as the Text property of the TextBox.

03

The View CheckBox toggles the PasswordChar property between String.Empty when checked and a character when un-checked.

When adding the nodes to the TreeList control, the images that appear are contained in an ImageList control that is added to the Form but which does not directly appear on the Form but instead in the tray below the Form.

04

After adding the ImageList control to the Form, click the small button with ellipsis i.e. three dots in front of the Images property to open the Image Collection Editor.

Continued to part 3... 


Index of all Solid Edge Tips, Tutorials and Videos...