프로그램 자료/Visual C#

C# 체크된 라디오버튼 찾기 Radiobutton Check Linq

motolies 2016. 10. 11. 09:42
출처 : http://stackoverflow.com/questions/1797907/which-radio-button-in-the-group-is-checked#1797955




아래와 같이 Linq를 사용하여 해당하는 콘트롤에서 해당 상태의 콘트롤을 가지고 올 수 있다.
라디오버튼 뿐 아니라 다른 콘트롤도 사용 가능하다.


var checkedButton = container.Controls.OfType<RadioButton>().FirstOrDefault(r => r.Checked);