How to Convert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miro

    How to Convert

    How can I convert this part of the line:
    Me.dgvmyData.Co lumns.Item("txt CellName") ' "txtCellNam e"
    which is within this line -
    Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(" txtCellName"),
    System.Componen tModel.ListSort Direction.Ascen ding)

    To read something like:
    Me.dgvmyData.Co lumns.Item( nonQuotedVariab le )

    So I do not have to use a "String" variable to specify the column name.
    I made an error in on one of my datagrids and Im sure there is a way to
    specify the column name without using a string character that could result
    in errors ( like I created ).

    Thanks

    Miro

  • James Hahn

    #2
    Re: How to Convert

    To use a non-quoted variable as the column identifier, simply assign the
    column name to a variable:

    nonQuotedVariab le = "txtCellNam e"
    Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(n onQuotedVariabl e),
    System.Componen tModel.ListSort Direction.Ascen ding)

    You are not using a "String" variable to specify the column name - you are
    using a string literal. The change suggested above replaces the string
    literal with a string variable. You must use string - either a literal or a
    variable, to identify the column.

    However, if you know the column index you can use an integer variable to
    specify the column in the sort instruction. Is your question that you don't
    know how to get the column index of a column where all you know is the
    column name?

    "Miro" <miro@beero.com wrote in message
    news:%23O4rCnnG JHA.2580@TK2MSF TNGP05.phx.gbl. ..
    How can I convert this part of the line:
    Me.dgvmyData.Co lumns.Item("txt CellName") ' "txtCellNam e"
    which is within this line -
    Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(" txtCellName"),
    System.Componen tModel.ListSort Direction.Ascen ding)
    >
    To read something like:
    Me.dgvmyData.Co lumns.Item( nonQuotedVariab le )
    >
    So I do not have to use a "String" variable to specify the column name.
    I made an error in on one of my datagrids and Im sure there is a way to
    specify the column name without using a string character that could result
    in errors ( like I created ).
    >
    Thanks
    >
    Miro
    >

    Comment

    • Miro

      #3
      Re: How to Convert


      "James Hahn" <jhahn@yahoo.co mwrote in message
      news:e3E$98pGJH A.3504@TK2MSFTN GP02.phx.gbl...
      To use a non-quoted variable as the column identifier, simply assign the
      column name to a variable:
      >
      nonQuotedVariab le = "txtCellNam e"
      Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(n onQuotedVariabl e),
      System.Componen tModel.ListSort Direction.Ascen ding)
      >
      You are not using a "String" variable to specify the column name - you are
      using a string literal. The change suggested above replaces the string
      literal with a string variable. You must use string - either a literal or
      a variable, to identify the column.
      >
      However, if you know the column index you can use an integer variable to
      specify the column in the sort instruction. Is your question that you
      don't know how to get the column index of a column where all you know is
      the column name?
      >
      "Miro" <miro@beero.com wrote in message
      news:%23O4rCnnG JHA.2580@TK2MSF TNGP05.phx.gbl. ..
      >How can I convert this part of the line:
      >Me.dgvmyData.C olumns.Item("tx tCellName") ' "txtCellNam e"
      >which is within this line -
      >Me.dgvmyData.S ort(Me.dgvmyDat a.Columns.Item( "txtCellNam e"),
      >System.Compone ntModel.ListSor tDirection.Asce nding)
      >>
      >To read something like:
      >Me.dgvmyData.C olumns.Item( nonQuotedVariab le )
      >>
      >So I do not have to use a "String" variable to specify the column name.
      >I made an error in on one of my datagrids and Im sure there is a way to
      >specify the column name without using a string character that could
      >result in errors ( like I created ).
      >>
      >Thanks
      >>
      >Miro
      >>
      >

      Hi James,

      I am not looking to "assign" my column name to a string variable... I am
      looking for something like this:
      ( I just dont know the right terminology I am looking for - it might be
      "IntelliSen se" )
      Lets pretend we are just dealing with this part of the line:
      Me.dgvmyData.Co lumns.Item("txt CellName")

      I am looking to do something like this:
      Me.dgvmyData.Co lumns.Item.txtC ellName

      (So I get an error at design time if I miss-spell txtCellName to
      txtCellTypoName vs getting an error at runtime)

      For example...
      Here is the same example how it would relate to with a typed dataset:

      Lets say I do this:
      Dim currentRow As DataRow
      'Then fill the datarow
      'Then to reference the datarow I would have to do something like this:
      currentRow ("AFieldInTheTa ble") = "Hello"

      But I am better off writing this example like this:
      Dim currentRow as Dataset.DataTab leRow
      'Then fill the datarow
      '*** Now notice how I cant make an error getting the field name because:
      currentRow.AFie ldInTheTable = "Hello"
      'is better than type this out currentRow ("AFieldInTypoT heTable") and now I
      get an exception error at runtime vs an error at design time.



      Thanks

      Miro





      Comment

      • Branco Medeiros

        #4
        Re: How to Convert

        Miro wrote:
        How can I convert this part of the line:
        Me.dgvmyData.Co lumns.Item("txt CellName")   ' "txtCellNam e"
        which is within this line -
        Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(" txtCellName"),
        System.Componen tModel.ListSort Direction.Ascen ding)
        >
        To read something like:
        Me.dgvmyData.Co lumns.Item( nonQuotedVariab le )
        >
        So I do not have to use a "String" variable to specify the column name.
        <snip>

        If you are defining the DataGridView content at design time, then the
        designer creates named columns for you, which you can use instead of
        refering to the columns by index or name.

        These automaticaly created columns will have names such as
        DataGridViewTex tBoxColumn1, DataGridViewTex tBoxColumn2, etc, or
        something like it, depending on how you created the association
        between the GridView and the data source.

        Suppose then, that the column you want to sort is for a field named
        CustomerName in the data source. Chances are you'll have a control
        named CustomerNameDat aGridViewTextBo xColumn (ouch!). You can use this
        control explicitly in your call to Sort:

        <example>
        Me.dgvmyData.So rt(Me.CustomerN ameDataGridView TextBoxColumn, _
        System.Componen tModel.ListSort Direction.Ascen ding)
        </example>

        (Personaly, I change all column names upon creation to something more
        manageable. You can do that by selecting "Edit Columns..." in the
        properties window and edit the column's (Name) field in the Design
        section)


        Hope this helps.

        Branco.

        Comment

        • James Hahn

          #5
          Re: How to Convert

          Since the column name can be changed at run time, it's not possible to hard
          code the name and be certain that there will not be an error at run time.
          Use the column index instead of the name. That virtually eliminates the
          possibility of a typo.

          "Miro" <miro@beero.com wrote in message
          news:OmoIRVsGJH A.1160@TK2MSFTN GP05.phx.gbl...
          >
          "James Hahn" <jhahn@yahoo.co mwrote in message
          news:e3E$98pGJH A.3504@TK2MSFTN GP02.phx.gbl...
          >To use a non-quoted variable as the column identifier, simply assign the
          >column name to a variable:
          >>
          >nonQuotedVaria ble = "txtCellNam e"
          >Me.dgvmyData.S ort(Me.dgvmyDat a.Columns.Item( nonQuotedVariab le),
          >System.Compone ntModel.ListSor tDirection.Asce nding)
          >>
          >You are not using a "String" variable to specify the column name - you
          >are using a string literal. The change suggested above replaces the
          >string literal with a string variable. You must use string - either a
          >literal or a variable, to identify the column.
          >>
          >However, if you know the column index you can use an integer variable to
          >specify the column in the sort instruction. Is your question that you
          >don't know how to get the column index of a column where all you know is
          >the column name?
          >>
          >"Miro" <miro@beero.com wrote in message
          >news:%23O4rCnn GJHA.2580@TK2MS FTNGP05.phx.gbl ...
          >>How can I convert this part of the line:
          >>Me.dgvmyData. Columns.Item("t xtCellName") ' "txtCellNam e"
          >>which is within this line -
          >>Me.dgvmyData. Sort(Me.dgvmyDa ta.Columns.Item ("txtCellName") ,
          >>System.Compon entModel.ListSo rtDirection.Asc ending)
          >>>
          >>To read something like:
          >>Me.dgvmyData. Columns.Item( nonQuotedVariab le )
          >>>
          >>So I do not have to use a "String" variable to specify the column name.
          >>I made an error in on one of my datagrids and Im sure there is a way to
          >>specify the column name without using a string character that could
          >>result in errors ( like I created ).
          >>>
          >>Thanks
          >>>
          >>Miro
          >>>
          >>
          >
          >
          Hi James,
          >
          I am not looking to "assign" my column name to a string variable... I am
          looking for something like this:
          ( I just dont know the right terminology I am looking for - it might be
          "IntelliSen se" )
          Lets pretend we are just dealing with this part of the line:
          Me.dgvmyData.Co lumns.Item("txt CellName")
          >
          I am looking to do something like this:
          Me.dgvmyData.Co lumns.Item.txtC ellName
          >
          (So I get an error at design time if I miss-spell txtCellName to
          txtCellTypoName vs getting an error at runtime)
          >
          For example...
          Here is the same example how it would relate to with a typed dataset:
          >
          Lets say I do this:
          Dim currentRow As DataRow
          'Then fill the datarow
          'Then to reference the datarow I would have to do something like this:
          currentRow ("AFieldInTheTa ble") = "Hello"
          >
          But I am better off writing this example like this:
          Dim currentRow as Dataset.DataTab leRow
          'Then fill the datarow
          '*** Now notice how I cant make an error getting the field name because:
          currentRow.AFie ldInTheTable = "Hello"
          'is better than type this out currentRow ("AFieldInTypoT heTable") and now
          I get an exception error at runtime vs an error at design time.
          >
          >
          >
          Thanks
          >
          Miro
          >
          >
          >
          >
          >

          Comment

          • Miro

            #6
            Re: How to Convert


            "Branco Medeiros" <branco.medeiro s@gmail.comwrot e in message
            news:a4fceb95-7891-4253-8496-b148a835b053@a7 0g2000hsh.googl egroups.com...
            Miro wrote:
            How can I convert this part of the line:
            Me.dgvmyData.Co lumns.Item("txt CellName") ' "txtCellNam e"
            which is within this line -
            Me.dgvmyData.So rt(Me.dgvmyData .Columns.Item(" txtCellName"),
            System.Componen tModel.ListSort Direction.Ascen ding)
            >
            To read something like:
            Me.dgvmyData.Co lumns.Item( nonQuotedVariab le )
            >
            So I do not have to use a "String" variable to specify the column name.
            <snip>

            If you are defining the DataGridView content at design time, then the
            designer creates named columns for you, which you can use instead of
            refering to the columns by index or name.

            These automaticaly created columns will have names such as
            DataGridViewTex tBoxColumn1, DataGridViewTex tBoxColumn2, etc, or
            something like it, depending on how you created the association
            between the GridView and the data source.

            Suppose then, that the column you want to sort is for a field named
            CustomerName in the data source. Chances are you'll have a control
            named CustomerNameDat aGridViewTextBo xColumn (ouch!). You can use this
            control explicitly in your call to Sort:

            <example>
            Me.dgvmyData.So rt(Me.CustomerN ameDataGridView TextBoxColumn, _
            System.Componen tModel.ListSort Direction.Ascen ding)
            </example>

            (Personaly, I change all column names upon creation to something more
            manageable. You can do that by selecting "Edit Columns..." in the
            properties window and edit the column's (Name) field in the Design
            section)


            Hope this helps.

            Branco.

            =============== ==

            Hi Branco,

            How did you get this example to work:
            <example>
            Me.dgvmyData.So rt(Me.CustomerN ameDataGridView TextBoxColumn, _
            System.Componen tModel.ListSort Direction.Ascen ding)
            </example>

            By putting 'just the txtColumnName' in the first variable of the sort - you
            will get a runtime error that the column does not exist in the datagridview.

            By going back to my original example, and using the
            Me.dgvmyData.Co lumns.Item("txt ColName") example, this only allows 2
            overloads. 1 is the column index, and 2 is the Name as string.
            I am looking for some overload to put the actual column name in there.

            I do not want to use the 'string' example cause I came accross this by
            making a type.
            I do not want to use a column index cause if i forget this 'sort' is in my
            code and i reference the index as a number and go re-arrange my grid later
            on - i will cause another bug.

            I am starting to think there is no way for intellisense to do this, Unless I
            create a quick 'do loop' and fly thru the columns in my datagrid view.
            Search for my "txtColName " - if it found it - use that column index, if it
            didnt, do not sort.
            Kind of silly but thats my only current solution.

            Miro






            Comment

            • Branco Medeiros

              #7
              Re: How to Convert

              Miro wrote:

              (1)
              <snip>
              How did you get this example to work:
              <example>
              Me.dgvmyData.So rt(Me.CustomerN ameDataGridView TextBoxColumn, _
                System.Componen tModel.ListSort Direction.Ascen ding)
              </example>
              >
              By putting 'just the txtColumnName' in the first variable of the sort - you
              will get a runtime error that the column does not exist in the datagridview.
              </snip>

              (2)
              <snip>
              By going back to my original example, and using the
              Me.dgvmyData.Co lumns.Item("txt ColName") example, this only allows 2
              overloads.  1 is the column index, and 2 is the Name as string.
              I am looking for some overload to put the actual column name in there.
              </snip>

              Hi, Miro!

              1) Of course, you must use the actual control name, I don't know how
              the editor named the controls for the columns you are using. To see
              the actual control name, right-click the grid, select "Edit
              columns...", select the column in the left panel (under "selected
              columns") and verify its name in the right panel (under "Bound Column
              Properties"). The control name will be in the (Name) field.

              2) Maybe I'm not being clear enough. I'm talking about the actual
              column control as parameter for the **DataGridView. Sort** method, not
              the parameter for the **DataGriView.C olumn.Item** property.

              These column controls were created automatically for you and are
              accessible at form level, just type Me, dot, and presto!, the control
              list will appear, pick the column control name from there! =))).
              (That's why I rename then, it's way easier to pick then up when you
              actually know the control's name! =))

              You are correct in not wanting to use the "string name" or the
              column's index. If you ever need a column's name or index, you can get
              then from the control itself (from the properties "Name", "Index" or
              "DisplayIndex") .

              Hope this helps.

              Branco.

              Comment

              • Miro

                #8
                Re: How to Convert


                "Branco Medeiros" <branco.medeiro s@gmail.comwrot e in message
                news:16214f0d-f46e-4121-9b86-bfa683614fe2@y3 8g2000hsy.googl egroups.com...
                Miro wrote:

                (1)
                <snip>
                How did you get this example to work:
                <example>
                Me.dgvmyData.So rt(Me.CustomerN ameDataGridView TextBoxColumn, _
                System.Componen tModel.ListSort Direction.Ascen ding)
                </example>
                >
                By putting 'just the txtColumnName' in the first variable of the sort -
                you
                will get a runtime error that the column does not exist in the
                datagridview.
                </snip>

                (2)
                <snip>
                By going back to my original example, and using the
                Me.dgvmyData.Co lumns.Item("txt ColName") example, this only allows 2
                overloads. 1 is the column index, and 2 is the Name as string.
                I am looking for some overload to put the actual column name in there.
                </snip>

                Hi, Miro!

                1) Of course, you must use the actual control name, I don't know how
                the editor named the controls for the columns you are using. To see
                the actual control name, right-click the grid, select "Edit
                columns...", select the column in the left panel (under "selected
                columns") and verify its name in the right panel (under "Bound Column
                Properties"). The control name will be in the (Name) field.

                2) Maybe I'm not being clear enough. I'm talking about the actual
                column control as parameter for the **DataGridView. Sort** method, not
                the parameter for the **DataGriView.C olumn.Item** property.

                These column controls were created automatically for you and are
                accessible at form level, just type Me, dot, and presto!, the control
                list will appear, pick the column control name from there! =))).
                (That's why I rename then, it's way easier to pick then up when you
                actually know the control's name! =))

                You are correct in not wanting to use the "string name" or the
                column's index. If you ever need a column's name or index, you can get
                then from the control itself (from the properties "Name", "Index" or
                "DisplayIndex") .

                Hope this helps.

                Branco.


                =============== ===============

                Hi Branco,

                I must still be missing something:

                My datagrid name is dgvRounds
                My column ( or one of them ) is named 'txtRounds' - i have already renamed
                it.
                I have my data filled in the datagrid.

                What I am understanding is that I can sort my datagrid like this ( by your
                code )

                Me.dgvRounds.So rt(Me.txtRound,
                System.Componen tModel.ListSort Direction.Ascen ding)

                The error I get - during runtime is:
                Column provided does not belong to this DataGridVew control

                The way I am adding the column is like this:
                On the form load:
                Dim index As Integer
                Dim dgvMaskedEdit As DataGridViewMas kedEditColumn 'custom class
                that is a masked edit column

                'find old column that is just a text box and remove it and add the
                masked edit text box in its place.
                index = dgvRounds.Colum ns.IndexOf(dgvR ounds.Columns(" txtRound"))
                dgvRounds.Colum ns.Remove("txtR ound")
                ' create a new custom column
                dgvMaskedEdit = New DataGridViewMas kedEditColumn
                dgvMaskedEdit.M ask = "###"
                dgvMaskedEdit.P romptChar = " "c
                dgvMaskedEdit.V alidatingType = GetType(Integer )
                dgvMaskedEdit.N ame = "txtRound"
                dgvMaskedEdit.D ataPropertyName = "PlayRound"
                dgvMaskedEdit.H eaderText = "Round"
                ' some more tweaking
                dgvMaskedEdit.S ortMode = DataGridViewCol umnSortMode.Pro grammatic
                ' insert the new column at the same location
                dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)


                ------
                so i can access Me.txtRound as a control, but I cannot figure out how to
                sort it by that column using the datagridview, unless i use "txtRound"


                You mentioned the "method"... im looking for help here:
                Learn how to customize sorting in the Windows Forms DataGridView control to create an alternate user interface.

                and cant seem to find what you are refering to.
                I have found this link:


                In the example given, it gets the index thru searching which column is
                selected.

                I know my index by index =
                dgvRounds.Colum ns.IndexOf(dgvR ounds.Columns(" txtRound"))


                Thank you for your patients.

                Miro










                Comment

                • Steve Gerrard

                  #9
                  Re: How to Convert

                  Miro wrote:
                  "Branco Medeiros" <branco.medeiro s@gmail.comwrot e in message
                  news:16214f0d-f46e-4121-9b86-bfa683614fe2@y3 8g2000hsy.googl egroups.com...
                  Miro wrote:
                  >
                  >
                  Me.dgvRounds.So rt(Me.txtRound,
                  System.Componen tModel.ListSort Direction.Ascen ding)
                  This will be compiled at compile time to refer to the existing column in the
                  datagrid.
                  dgvRounds.Colum ns.Remove("txtR ound") ' create a new custom
                  Now it is not in the grid.
                  dgvMaskedEdit.N ame = "txtRound"
                  ' insert the new column at the same location
                  dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)
                  That's not the same column, even if it has the same name. :(





                  Comment

                  • Branco Medeiros

                    #10
                    Re: How to Convert

                    Miro wrote:
                    <snip>
                    My datagrid name is dgvRounds
                    My column ( or one of them ) is named 'txtRounds' - i have already renamed
                    it.
                    I have my data filled in the datagrid.
                    >
                    What I am understanding is that I can sort my datagrid like this ( by your
                    code )
                    >
                    Me.dgvRounds.So rt(Me.txtRound,
                    System.Componen tModel.ListSort Direction.Ascen ding)
                    >
                    The error I get - during runtime is:
                    Column provided does not belong to this DataGridVew control
                    >
                    The way I am adding the column is like this:
                    On the form load:
                            Dim index As Integer
                            Dim dgvMaskedEdit As DataGridViewMas kedEditColumn  'custom class
                    that is a masked edit column
                    >
                            'find old column that is just a text box and remove it and add the
                    masked edit text box in its place.
                            index = dgvRounds.Colum ns.IndexOf(dgvR ounds.Columns(" txtRound"))
                            dgvRounds.Colum ns.Remove("txtR ound")
                    <snip>
                            dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)
                    <snip>

                    As Steve pointed out, once you remove txtRound from the grid, it
                    doesn't belong to the gridview anymore. The column you must use to
                    sort is dgvMaskedEdit.

                    <example>
                    Me.dgvRounds.So rt(Me.dgvMasked Edit, _
                    System.Componen tModel.ListSort Direction.Ascen ding)
                    </example>

                    The runtime "Name" property has (almost) nothing to do with the
                    control's name, which is what you must use =))

                    Hope that helped.

                    Branco.

                    Comment

                    • Miro

                      #11
                      Re: How to Convert

                      Thank you Steve and Branco,

                      I have tested out what you have said and you are correct. -As you
                      suspected, and as I suspected :-)
                      -By me not "removing" the field, I can directly sort on it using the
                      Me.txtRounds control name.

                      I just dont seem to understand why the original code does fail still.
                      I am adding my "column" back into the datagridview as a column so therefore
                      it does exist in the controls collection.
                      So,
                      dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)
                      should be adding the "txtRound" column into the dgvRounds.Colum ns collection

                      My problem is that I cannto use dgvMaskedEdit as its only decalred in a mini
                      sub, and is re-used about 5 or 6 times replacing a couple columns.

                      If this is not really changing the "Name"
                      >dgvMaskedEdit. Name = "txtRoundTi me"
                      "The runtime "Name" property has (almost) nothing to do with the
                      control's name, which is what you must use =))"

                      Then I am assuming there is no real way to change the runtime's name to be
                      the REAL controls NAME property?

                      Thanks

                      Miro


                      "Branco Medeiros" <branco.medeiro s@gmail.comwrot e in message
                      news:95410d00-91e5-440b-8797-c992c1bc8708@f6 3g2000hsf.googl egroups.com...
                      Miro wrote:
                      <snip>
                      My datagrid name is dgvRounds
                      My column ( or one of them ) is named 'txtRounds' - i have already renamed
                      it.
                      I have my data filled in the datagrid.
                      >
                      What I am understanding is that I can sort my datagrid like this ( by your
                      code )
                      >
                      Me.dgvRounds.So rt(Me.txtRound,
                      System.Componen tModel.ListSort Direction.Ascen ding)
                      >
                      The error I get - during runtime is:
                      Column provided does not belong to this DataGridVew control
                      >
                      The way I am adding the column is like this:
                      On the form load:
                      Dim index As Integer
                      Dim dgvMaskedEdit As DataGridViewMas kedEditColumn 'custom class
                      that is a masked edit column
                      >
                      'find old column that is just a text box and remove it and add the
                      masked edit text box in its place.
                      index = dgvRounds.Colum ns.IndexOf(dgvR ounds.Columns(" txtRound"))
                      dgvRounds.Colum ns.Remove("txtR ound")
                      <snip>
                      dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)
                      <snip>

                      As Steve pointed out, once you remove txtRound from the grid, it
                      doesn't belong to the gridview anymore. The column you must use to
                      sort is dgvMaskedEdit.

                      <example>
                      Me.dgvRounds.So rt(Me.dgvMasked Edit, _
                      System.Componen tModel.ListSort Direction.Ascen ding)
                      </example>

                      The runtime "Name" property has (almost) nothing to do with the
                      control's name, which is what you must use =))

                      Hope that helped.

                      Branco.

                      Comment

                      • Steve Gerrard

                        #12
                        Re: How to Convert

                        Miro wrote:
                        >
                        If this is not really changing the "Name"
                        >dgvMaskedEdit. Name = "txtRoundTi me"
                        >
                        "The runtime "Name" property has (almost) nothing to do with the
                        control's name, which is what you must use =))"
                        >
                        Then I am assuming there is no real way to change the runtime's name
                        to be the REAL controls NAME property?
                        >
                        You are confusing the Name property with the name given to a reference variable
                        in your code.

                        When you do Dim txtRounds As TextColumn, you have a reference variable for a
                        column. Often, but not always or necessarily, the column will also have its Name
                        property = "txtRounds" . But that is the Name of the column, not the name of your
                        reference variable.

                        Once you do
                        dgvMaskedEdit = New DataGridViewMas kedEditColumn

                        you can assign it any Name you like. But if you want to refer to the column by a
                        variable, use dgvMaskedEdit, not the column name.

                        Once you have done
                        dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)

                        you should be able to sort by that column using
                        dgvRounds.Sort( dgvMaskedEdit)

                        The only use for the Name would be something like
                        dgvRounds.Sort( dgvRounds.Colum ns.Item("txtRou nds"))

                        which pretty much defeats the intent of not using string names.





                        Comment

                        • Miro

                          #13
                          Re: How to Convert

                          Thank you for the explination. -I think I understand.

                          Much appreciated, and thanks for being patient.

                          Cheers'

                          Miro

                          "Steve Gerrard" <mynamehere@com cast.netwrote in message
                          news:JOqdnUfns8 RhxkfVnZ2dnUVZ_ qninZ2d@comcast .com...
                          Miro wrote:
                          >>
                          >If this is not really changing the "Name"
                          >>dgvMaskedEdit .Name = "txtRoundTi me"
                          >>
                          >"The runtime "Name" property has (almost) nothing to do with the
                          >control's name, which is what you must use =))"
                          >>
                          >Then I am assuming there is no real way to change the runtime's name
                          >to be the REAL controls NAME property?
                          >>
                          >
                          You are confusing the Name property with the name given to a reference
                          variable in your code.
                          >
                          When you do Dim txtRounds As TextColumn, you have a reference variable for
                          a column. Often, but not always or necessarily, the column will also have
                          its Name property = "txtRounds" . But that is the Name of the column, not
                          the name of your reference variable.
                          >
                          Once you do
                          dgvMaskedEdit = New DataGridViewMas kedEditColumn
                          >
                          you can assign it any Name you like. But if you want to refer to the
                          column by a variable, use dgvMaskedEdit, not the column name.
                          >
                          Once you have done
                          dgvRounds.Colum ns.Insert(index , dgvMaskedEdit)
                          >
                          you should be able to sort by that column using
                          dgvRounds.Sort( dgvMaskedEdit)
                          >
                          The only use for the Name would be something like
                          dgvRounds.Sort( dgvRounds.Colum ns.Item("txtRou nds"))
                          >
                          which pretty much defeats the intent of not using string names.
                          >
                          >
                          >
                          >
                          >

                          Comment

                          Working...