Cites this verse
And was it not likewise of his own will that the wicked son of Gera cursed King David? And yet what says David, full of true, and deep, and pious wisdom? What did he say to him who wanted to smite the reviler? "What," said he, "have I to do with you, ye sons of Zeruiah? Let him alone and let him curse, because the Lord hath said unto him, Curse David. Who, then, shall say, Wherefore hast thou done so?" And then the inspired Scripture, as if it would confirm the king's profound utterance by repeating it once more, tells us: "And David said to Abishai, and to all his servants, Behold, my son, which came forth from my bowels, seeketh my life: how much more may this Benjamite do it! Let him alone, and let him curse; for the Lord hath bidden him. It may be that the Lord will look on my humiliation, and will requite me good for his cursing this day." Now what prudent reader will fail to understand in what way the Lord bade this profane man to curse David? It was not by a command that He bade him, in which case his obedience would be praiseworthy; but He inclined the man's will, which had become debased by his own perverseness, to commit this sin, by His own just and secret judgment. Therefore it is said, "The Lord said unto him." Now if this person had obeyed a command of God, he would have deserved to be praised rather than punished, as we know he was afterwards punished for this sin. Nor is the reason an obscure one why the Lord told him after this manner to curse David. "It may be," said the humbled king, "that the Lord will look on my humiliation, and will requite me good for his cursing this day." See, then, what proof we have here that God uses the hearts of even wicked men for the praise and assistance of the good.
On Grace and Free Will, Chapter 41