It may be difficult, if even at all possible for you to imagine how it is to be grateful for things that bring you down. It may not even be necessary all the time, though in some situations this could be a very reasonable approach. It would be difficult to achieve such a level of selflessness like for example Dalai Lama has, expressing grateful attitude to the oppressors. However, in simple situations, that make you lose control or adopt a victim attitude, it is possible.
This all comes down to the perception. When you see your obstacles from the angle of a lesson to be learned, you automatically make the experience less painful. For example, when you get cheated on financially, it is understandable that you become sad, disappointed and bitter, and still, when you see it as a lesson for the future to be alert in a similar situation, you could avoid potentially higher losses. And maybe a situation comes, and you avoid this scam happening to you, you would recall the lesson and think “How grateful I am now that I experienced it with such an insignificant amount which taught me a lesson which now saved my financial wellbeing”.