質問

I am new in using custom controls.

I have created a custom control in my winform application that inherited of ultragrid. I can not paste my codes here but i explain it below:

  1. I have set some of properties such as CellClickAction and HeaderClickAction in OnPaint method before base.OnPaint(pe); command that changed the appearance and behavior of the ultragrid.

  2. I have added a ContextMenuStrip control with 3 items (Ascending, Descending, None) that should use in Mouse Up event.

  3. I have wrote an event handler for Mouse Up event of ultragrid that should find the caption of clicked header (if the user clicked on header) and do a 3way sorting by check and then change the SortIndicator property of that clicked column (if the left mouse button clicked) or show a ContextMenuStrip on that column (if the right mouse button clicked).

  4. I have wrote an event handler for Item Clicked event of ContextMenuStrip that sort the grid based on clicked item.

Now the problem is when i want to use my grid in a form.Every things doing slowly and sometimes visual studio become locking or if for example i add a button to the form with MessageBox.Show(""); command on its clicked event handler and then run, and click on this button the form locking.

can any one tell me what is my mistake? please feel free to ask me about my question.

役に立ちましたか?

解決 2

Akh joooon, Thanks all.I found where the problem is...It was in OnPaint event. but not in CellClickAction or HeaderClickAction,It was in appearance properties,ActiveRowAppearance and SelectedRowAppearance.because i had set them too.I commented them and now every thing is fine.

他のヒント

You can try to pause the debugging when the form "lock", and walk up the call stack to understand where the code i locked (or probably doing an infinite loop or something similar)

But, for this kind of personalization, you can also create a "configurator" class that take an instance of ultragrid, and then add all the handler, so all your personalization code remain inside this "configurator" class.
If you need a lot of personalization, maybe a custom control is worth it... but if the personalization is just some event handler, keeping all the code in a specific class maybe easier to manage.

Creating custom control is something that require a lot of expertise, and always come with many quirks and uncommon issue... you need to define all properties default value, define other properties attribute to have a proper design time support, withstand the oddities of visual studio IDE and it's crash...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top