CSConnect.cParameters.getByPosition C# (CSharp) Method

getByPosition() public method

public getByPosition ( int position ) : cParameter
position int
return cParameter
        public cParameter getByPosition(int position)
        {
            for (var i = 0; i < count(); i++)
            {
                cParameter p = item(i);
                if (p.getPosition() == position) 
                {
                    return p;
                }
            }
            throw new Exception("This parameters collection doesn't contain a parameter with a position = " + position.ToString());
        }

Usage Example

Example #1
0
        private void loadParameters()
        {
            int top = 20;

            m_texts = new TextBox[m_parameters.count()];

            for (int j = 0; j < m_parameters.count(); j++)
            {
                cParameter parameter = m_parameters.getByPosition(j + 1);

                System.Windows.Forms.Label label = new System.Windows.Forms.Label();
                label.AutoSize = true;
                label.Location = new System.Drawing.Point(30, top);
                label.Text     = parameter.getName();

                System.Windows.Forms.TextBox input = new System.Windows.Forms.TextBox();
                input.Location = new System.Drawing.Point(150, top);
                input.Size     = new System.Drawing.Size(150, 20);
                input.Text     = parameter.getValue();
                input.Tag      = parameter.getKey();

                switch (parameter.getColumnType())
                {
                case csDataType.CSTDLONGVARCHAR:
                case csDataType.CSTDCHAR:
                    input.Tag = "T";
                    break;

                case csDataType.CSTDBIGINT:
                case csDataType.CSTDBINARY:
                case csDataType.CSTDINTEGER:
                case csDataType.CSTDSMALLINT:
                case csDataType.CSTDTINYINT:
                case csDataType.CSTDUNSIGNEDTINYINT:
                    input.Tag = "N";
                    break;

                case csDataType.CSTDBOOLEAN:
                    input.Tag = "N";
                    break;

                case csDataType.CSTDSINGLE:
                case csDataType.CSTDDECIMAL:
                case csDataType.CSTDDOUBLE:
                    input.Tag = "N";
                    break;

                case csDataType.CSTDDBTIME:
                    input.Tag = "F";
                    break;
                }

                m_texts[j] = input;

                pnlParameters.Controls.Add(label);
                pnlParameters.Controls.Add(input);

                top += 30;
            }
        }