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" <br************ *@gmail.comwrot e in message
news:95******** *************** ***********@f63 g2000hsf.google groups.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.