We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Modify drag&drop coursor, and modify the target rectangle

Hi,
I need to modify the drag&drop mouse-cursor of the grid control. The cursor looks like an arrow with a small dashed box. I need to change the color of the box to red. Where can I do it?

Second question : when the cell (or row) is draged, then the target cell (or row) is marked with a dashed rectangle. I need to change the color of this rectangle to red as well. Where can I do it?

Can you send me some code-examples please?
Thank you!
Regards Daniel

5 Replies

HA haneefm Syncfusion Team May 24, 2007 04:06 PM UTC

Hi Dan,

Issue 1 : Change Cursor.
>>>>>>>>>>>>>>>>>>>>>>>>>>
Below is a KB article that shows you "How do I change the mouse cursor in a GridControl?"
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=69

Issue 2 : Change DragDrop rectangle Color.
>>>>>>>>>>>>>>>>>>>>>>>>>>
This can be achieved in two ways. One technique will be to derive the grid control and override OnMouseDown method. Below is a sample that show this task.

Sample :DragDropGridControlV.zip

Another way will be to create your own mouse controller class to have the desired dragging effect. You need to replace the existing MouseController for dragging columns with an alternate MouseController in which you handle outlining the borders with color.

Please refer these forum threads for more information on this.
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=29949
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=35930

Best regards,
Haneef


DD Daniel Dusek May 25, 2007 12:24 PM UTC

Hi Haneef,
thank you for your help so far. I am now trying to implement the first problem. I do it in the third way described in the example, which is a custom mouse-event-handler, a class which implements IMouseController. It works quite well, but I have one problem : I have to re-write the example from c# to c++ (I have to use c++). And I can't get the stream object from the cursor. The stream is always NULL:

System::IO::Stream * stream = control->GetType()->Module->Assembly->GetManifestResourceStream(S"HierarchicalGridNS::COPY4WAY.CUR");


Do you have some example in c++ as well? Or some hint how to create the stream object for the cursor in c++?

Thank you!
Regads Dan


HA haneefm Syncfusion Team May 25, 2007 07:15 PM UTC

Hi Dan,

The reason for getting this issue is that you are not setting the "COPY4WAY.CUR" file build action as Embeded Resource. By default, it should be content. Please try the following steps to resolve this.

1) Open your application
2) Right click on the "COPY4WAY.CUR" file in the solution explorer and go the properties.
3) set the Build Action to Embeded Resource in properties.
4) Run your application.

Reading the information from the resource to a stream is performed with a method call to GetManifestResourceStream. The parameter that is passed to this method is the name of the resource that is to be accessed. The resources are named using the following convention: .. So if you embed a file named minus.bmp into your project in the MyNS namespace, you have a resource in the manifest named MyNS.minus.bmp.If you want to get resource streams, use the following code:

Bitmap bm = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream("MyNS.COPY4WAY.CUR"));

The only tricky thing here is you need to prepend the name of your Assembly to the name of the resource stream. If you want to view all the resource streams available to you, use the following code:

Assembly a = Assembly.GetExecutingAssembly();
string resNames[ ] = a.GetManifestResourceNames();

foreach(string s in resNames)
{
Console.WriteLine(s);
}

Best regards,
Haneef


DD Daniel Dusek May 30, 2007 11:46 AM UTC

Hi Haneef,
thank you very much, so far I have finished the first problem, the mouse cursor. By the way, in c++ it is not such a property like BuildAction. You have to do this : go to Project properties - Configuration properties - Linker - Input : 'Embed managed resource file' and write the name of the cursor file you want to use, e.g. 'OUR_DRAG_DROP.CUR' and recompile the project. Then this code will work :
__property System::Windows::Forms::Cursor * get_Cursor()
...
Control * control = m_gridControl->Parent;
while(control->Parent != NULL)
{
control = control->Parent;
}


System::IO::Stream * stream = control->GetType()->Module->Assembly->GetManifestResourceStream(S"OUR_DRAG_DROP.CUR");

if (stream != NULL)
{
m_mouseCursor = new System::Windows::Forms::Cursor(stream);
}

The file OUR_DRAG_DROP.CUR must be located in the same directory as the projekt.

BUT : the second problem is still not solved. I use my own mouse controller now, so I want to modify the target preselected rectangle in this controller. But where? How shoud I do this? I did not find the example 'MouseController', can you send me a link to it? The other examples you have mentioned did not helped me as well :-(.

Thank you so far, regards Dan


HA haneefm Syncfusion Team May 31, 2007 10:08 PM UTC

Hi Dan,

Please follow the below forum thread for more details.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=61704

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon