Question: When one has depression, is it an illness of the brain (which has form), or a mental illness (which is formless)?
Answer: According to Buddhism, the mind is the forerunner of all things, ‘with all only by the mind created’ (一切唯心造). This means the mind karmically created the cause for depression, which is then reflected in brain changes. Science at the moment might tend to say it is the other way round, that chemical imbalances and such cause depression. Even if so, the mind still created the karma earlier (i.e in the present or a past life) to cause these changes. Thus, the mind is still the forerunner. So, mental illness is first formless, before it takes form later.
Question: When one with depression dies, will he or she still have depressive thoughts?
Answer: Upon death, as depressive persons are no longer conditioned by the brain, they should no longer be depressed… unless there are new thoughts that are depressing in nature arising.
Question: Does this mean the depressed person might still have depressive thoughts then?
Answer: Yes, if the mind intentionally (or habitually) continues being depressive, with this meaning the depression is mind-centred. No, if the depression is brain-centred, with this meaning the depression karmically ends when brain function physically ends.
Question: What are wider implications of this?
Answer: This means suicide is never a solution for the depressed. Suicide does not end depression. Even if the depression is more brain-based, the act of suicide requires great (self-)hatred, violence and harm to a human being (i.e. oneself), which creates intense evil karma, that can swiftly lead to a worse rebirth with more suffering, in both body and mind, possibly in a lower realm. This is leaping out of the frying pan into the fire.
To conclude, there should instead be more sincere and diligent learning and practice of the Dharma to transform depression to peace of mind. To prevent aggravation before this is possible, seeking qualified medical treatment is wise too.