본문 바로가기

C# Winform

C# Winform | properties settings 저장

by C기억저장소 2020. 3. 5.

C# Winform | properties settings 저장

 

.NET Framework 2.0부터 수 만들고 응용 프로그램 실행 세션 간에 유지 되는 값에 액세스 합니다. 이러한 값 이라고 설정을합니다. 응용 프로그램의 중요 한 정보를 사용 해야 합니다. 또는 설정에는 사용자 기본 설정에 나타낼 수 있습니다. 예를 들어 일련의 응용 프로그램의 색 구성표에 대 한 사용자 기본 설정을 저장 하는 설정 만들 수 있습니다. 또는 응용 프로그램을 사용 하는 데이터베이스를 지정 하는 연결 문자열을 저장할 수 있습니다. 설정을 코드 외부에 있고 개별 사용자의 기본 설정을 저장 하는 프로필을 만드는 응용 프로그램에 중요 한 정보를 유지 하 둘 다를 수 있습니다.

 

  설정

 

1. [프로젝트 탐색기]에서 Properties 하위 폴더인 Settings.settings를 더블 클릭한다.

프로젝트 탐색기

2. 이름, 형식[데이터 타입], 값을 입력한다.

3. 준비가 완료되었으면 다음과 같이 읽고 저장할수 있다.

 

  Read

MSDN

 

How To: Read Settings at Run Time With C# - Windows Forms .NET Framework

Learn how to read both Application-scoped and User-scoped settings at run time with C# via the Properties object.

docs.microsoft.com

 

this.BackColor = Properties.Settings.Default.myColor;
cs
 

 

 

  Write

MSDN

 

How To: Write User Settings at Run Time with C# - Windows Forms .NET Framework

Learn how to write settings at run time with C# by persisting the changes to the settings between application sessions by calling the Save method.

docs.microsoft.com

 

Properties.Settings.Default.myColor = Color.AliceBlue;
Properties.Settings.Default.Save();  
cs