问:

To the surprise of ....做什么句子成分

答:
在句子中,to the surprise of 充当的是介词短语作定语的句子成分。它修饰句子的主语或宾语,表示“令某人惊讶的是...”的意思。
例句:
To the surprise of everyone, he suddenly resigned from the company.
令每个人惊讶的是,他突然从公司辞职了。
在这个例句中,to the surprise of everyone 充当主语he的定语,修饰和限定主语he,表示主语he的辞职行为令每个人感到惊讶。
To the surprise of the teacher, the worst student got the highest score in the exam. 
令老师惊讶的是,成绩最差的那个学生考试得了最高分。
在这个例句中,to the surprise of the teacher 充当宾语the highest score的定语,修饰和限定宾语the highest score,表示 obtaining the highest score令老师感到惊讶。
所以,to the surprise of在句子中主要充当定语的句子成分,修饰句子的主语或宾语,表示某个让人感到惊讶的事实或行为,起到“令某人惊讶的是...”的定语从句的作用。它可以帮助增强句子的描写性和表达性,突出某个令人意外的情况。
如果您有任何其他关于句子成分或句法结构的问题,欢迎提出,我将进行详细的说明与分析。