Thank you JohnH. Finally got it working along with the rest of my code.
The last code I posted was for a Custom User Control, which I realise I don't need now you have given me an example to explain it.
Thank you again for the help and also vis781
Holly Max
OK this is the Custom Control I created.
Using the line
I get the following error
Custom Control code
PublicClass MyDataGrid
Inherits DataGrid
'Inherits System.Windows.Forms.DataGrid
#Region " Windows Form Designer generated code "
PublicSubNew()
MyBase.New()
'This call is required by...
Also I didn't post the C# code laid out in case I missed part of the code in amongst the article. That's why I posted the whole thing as it was. I've never done any C# coding. I have read some and can sometimes follow what the vb.net equivalent is or should be.
Thanks for the help so far. Now is this code used as a User Control, or how do I replace the standard datagrid with MyDataGrid (or make the reference to this new control)?
I know you haven't tested it but can you see any problems using this type of method to acheive what I am trying to do...
This is the whole article. Hope this helps you.
"This code sorts a Windows.Forms.DataGrid programmatically, "emulating" a header click"
Introduction
This article shows, how to programmatically sort a System.Windows.Forms.DataGrid. In other words, how to emulate a "click" on a column header...
I need to sort a datagrid control by programatically clicking the column header of a Datagrid. I have seen code in C# that uses the datagrid's private method ColumnHeaderClicked, but this is beyond me.
My problem is that if I use the .DefaultView.Sort I loose the binding I need to text boxes...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.