Smrf.NodeXL.ExcelTemplate.AddSelectedVerticesToGroupDialog.DoDataExchange C# (CSharp) Method

DoDataExchange() protected method

protected DoDataExchange ( Boolean bFromControls ) : Boolean
bFromControls Boolean
return Boolean
    DoDataExchange
    (
        Boolean bFromControls
    )
    {
        if (bFromControls)
        {
            String sGroupName;

            if ( !ValidateRequiredComboBox(cbxGroupName,

                "Either select the name of an existing group from the"
                + " drop-down list, or enter a new group name.", 

                out sGroupName) )
            {
                return (false);
            }

            // We need to determine whether the group name is an existing group
            // that was selected from the drop-down list, or a new group name
            // that was typed.  SelectedItem is empty when text is typed, so
            // that seems like an adequate test.  However, the user may have
            // typed an existing group name with leading or trailing spaces,
            // which ValidateRequiredComboBox() removed, and an empty
            // SelectedItem would give an incorrect answer in this case.
            //
            // Instead, take the trimmed Text property that
            // ValidateRequiredComboBox() returned and search for it in the
            // ComboBox's drop-down list.

            Int32 iGroupNameIndex = cbxGroupName.FindString(sGroupName);
            m_bIsNewGroup = (iGroupNameIndex == -1);

            if (m_bIsNewGroup)
            {
                m_sGroupName = sGroupName;
            }
            else
            {
                // ComboBox.FindString() does a case-insensitive search.  We
                // don't want "G1" and "g2" to be separate groups, so retrieve
                // the exact spelling of the existing group name.

                m_sGroupName = (String)cbxGroupName.Items[iGroupNameIndex];
            }
        }
        else
        {
            // (Do nothing.)
        }

        return (true);
    }