DB2 시간지연 쿼리
WITH TAB1 (NUM,TS1,TS2) AS ( VALUES
(
INT(1) ,
TIMESTAMP(GENERATE_UNIQUE()) ,
TIMESTAMP(GENERATE_UNIQUE())
)
UNION ALL
SELECT
NUM + 1 ,
TS1 ,
TIMESTAMP(GENERATE_UNIQUE())
FROM
TAB1
WHERE
  TIMESTAMPDIFF(2,CHAR(TS2-TS1)) < 지연초
)
SELECT
MAX(NUM) AS #LOOPS ,
MIN(TS2) AS BGN_TIMESTAMP ,
MAX(TS2) AS END_TIMESTAMP
FROM TAB1;



by 딸기아부지 | 2011/08/17 13:50 | DB관련 주워온 글 | 트랙백
AMI BIOS 날렸을때 복구방법

정상벅인 바이오스의 이름이 A6728IMS.250 라고 할 경우

AMIBOOT.ROM 으로 바꾸고


부팅 디스켓이 아닌 포맷한 디스크에 넣고 파워 온

CTRL + HOME 키를 누르고 있는다

by 딸기아부지 | 2011/08/16 22:50 | 기타잡기 | 트랙백
COleDateTime 관련

원본: http://kgpark.net/tools/tag/COleDateTime?TSSESSION=109cc45945c763a714e0dc4668142de2

시간에 대한 제어가 필요한 적이 있었다.

그런데.. 막상 어떻게 해야 할지 떠오르지 않았다..

그래서 막 찾고.. 막 알아봤다..

Windows 프로그램이라면.. COleDateTime Class 를 사용하면된다.

간단하다 생성자는 여러개가 있지만..

간단한 것으로는 6개의 인자를 받으면 된다.

COleDateTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec) 의 값을 주면 된다..

현재의 시간을 받고 싶다면..

COleDateTime thisTime(COleDateTime::GetCurrentTime());

이렇게 하면 되고.

제어는 얻어올 때는 GetYear(), GetMonth() , ~~~ 이 있고.

값을 바꿀 때는 SetDate(int nYear, int nMonth, int nDay), SetTime(int nHour, int nMin, int nSec), SetDateTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec) 등이 있다.

그리고 두 COleDateTime 객체간의 차이를 구할 때는

COleDateTime ATime(2007, 4, 26, 17, 20, 30); COleDateTime BTime(2007, 4, 26, 18, 20, 50);

COleDateTimeSpan C = BTime - ATime;

C.GetTotalDays() - 차이나는 총 날짜 C.GetTotalHours() - 차이나는 총 시간 C.GetTotalMinutes() - 차이나는 총 분 C.GetTotalSeconds() - 차이나는 총 초

등을 알 수 있다..ㅎㅎ 내용을 추가한다. CString 으로 바꾸고 싶다면.. 멤버 함수 Format 을 사용하면 된다.

COleDateTime nowTime(COleDateTime::GetCurrentTime()); OutputDebugString(nowTime.Format(_T("%H:%M:%S\n")));

Format 에 들어가는 것은

%a     Abbreviated weekday name
%A     Full weekday name
%b     Abbreviated month name
%B     Full month name
%c     Date and time representation appropriate for locale
%d     Day of month as decimal number (01 – 31)
%H     Hour in 24-hour format (00 – 23)
%I      Hour in 12-hour format (01 – 12)
%j      Day of year as decimal number (001 – 366)
%m    Month as decimal number (01 – 12)
%M   Minute as decimal number (00 – 59)
%p    Current locale's A.M./P.M. indicator for 12-hour clock
%S    Second as decimal number (00 – 59)
%U    Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w   Weekday as decimal number (0 – 6; Sunday is 0)
%W   Week of year as decimal number, with Monday as first day of week (00 – 53)
%x    Date representation for current locale
%X    Time representation for current locale
%y    Year without century, as decimal number (00 – 99)
%Y   Year with century, as decimal number
%z, %Z  Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%   Percent sign
와 같다.. 자주 쓰일만한 것은 %Y/%m/%d %H:%M:%S 이렇게 쓰면 될 것 같다.. 2009년 3월 17일 오후 3시 41분 20초일 경우 -> 2009/03/17 15:41:20 이렇게 사용할 수 있다.ㅎㅎ
top

Trackback Address :: http://kgpark.net/tools/trackback/19

  1. Tracked from jc penneys catalogue printable coupon 2011/08/03 21:34 DELETE

    Subject: jc penneys catalogue printable coupon

    character counts certificates printables <a href="http://www.epcool.fi/tmp/templates_c/page.php?k=character-counts-certificates-printables">character counts certificates printables</a> printable multicultural paper dolls wreath <a href="http://www.learn..
  2. Tracked from free printable baby shower inviations 2011/08/03 22:23 DELETE

    Subject: free printable baby shower inviations

    fake blank printable birth certificate <a href="http://www.psychoteam.net/zxfake-blank-printable-birth-certificate/">fake blank printable birth certificate</a> printable material for children ministry <a href="http://patriotsborderalliance.org/phprintab..
  3. Tracked from college math printable worksheets 2011/08/03 22:55 DELETE

    Subject: college math printable worksheets

    print perfect printable tickets <a href="http://www.progreenpainting.org/modules/News/page.php?k=print-perfect-printable-tickets">print perfect printable tickets</a> printable thanksgiving coloring sheets <a href="http://www.keywestfishingpackages.com/t..
  4. Tracked from printable home health care forms 2011/08/03 23:23 DELETE

    Subject: printable home health care forms

    cursive handwriting printable practice sheets <a href="http://www.epcool.fi/tmp/templates_c/page.php?k=cursive-handwriting-printable-practice-sheets">cursive handwriting printable practice sheets</a> printable file foder games <a href="http://www.epcool..
  5. Tracked from math mutliplication printable puzzles 2011/08/04 00:45 DELETE

    Subject: math mutliplication printable puzzles

    rosary prayers book printable <a href="http://plush-mir.ru/brrosary-prayers-book-printable/">rosary prayers book printable</a> free blank printable sheet music <a href="http://www.fortis.sk/plus/wp-page.php?k=free-blank-printable-sheet-music">free blank..
  6. Tracked from free printable japanese greetings 2011/08/04 02:15 DELETE

    Subject: free printable japanese greetings

    school related scrapbooking printables <a href="http://parantavantaiteenry.net/modules/ABFlashGallery/page.php?k=school-related-scrapbooking-printables">school related scrapbooking printables</a> sat math tutorial printable <a href="http://www.loyaltywo..
  7. Tracked from black and white easter printables 2011/08/04 03:45 DELETE

    Subject: black and white easter printables

    fall kids craft ideas printables <a href="http://petrasekjan.eu/htfall-kids-craft-ideas-printables/">fall kids craft ideas printables</a> printable birthday cards with picture <a href="http://muscle.bz/hcprintable-birthday-cards-with-picture/">printable..
  8. Tracked from printable 2009 nba schedule 2011/08/04 05:02 DELETE

    Subject: printable 2009 nba schedule

    free printable test for legends <a href="http://profeng.ru/lib/classes/page.php?k=free-printable-test-for-legends">free printable test for legends</a> mall of america printable map <a href="http://www.cantonales2011cessonacigne.fr/ghmall-of-america-prin..
  9. Tracked from printable philadelphia eagle logo 2011/08/04 06:22 DELETE

    Subject: printable philadelphia eagle logo

    free happy birthday printable <a href="http://www.cmsms.kluvers.net/xzfree-happy-birthday-printable/">free happy birthday printable</a> free printable drawing conclusions worksheets <a href="http://www.kebabylon.net/styles/prosilver/page.php?k=free-prin..
  10. Tracked from free printable language worksheets 2011/08/04 07:47 DELETE

    Subject: free printable language worksheets

    burrowing owl printable coloring pictures <a href="http://www.ericvdp.com.au/modules/Printing/page.php?k=burrowing-owl-printable-coloring-pictures">burrowing owl printable coloring pictures</a> birthday card turkey printable <a href="http://www.bayviewg..
  1. nicec 2009/10/12 16:35 PERMALINKMODIFY/DELETE REPLY

    감사합니다~~ㅎㅎ

by 딸기아부지 | 2011/08/16 13:22 | 윈도우관련 | 트랙백(1)
System ParaC#에서 meter정보 가져오기
원본: http://www.whatisthat.co.kr/65 

System ParaC#에서 meter정보 가져오기
System Parameter와 관련된 정보를 가져 오기 위하여 Win32 API를 사용하는 경우가 많이 있습니다.
API를 사용한다고 해서 틀렸다 라고 할 수는 없지만, 일부 API가 특정 OS Version사용방법이 조금씩 차이가 있다는 점으로 미루어 볼 때, .Net Framework 에서 제공하는 방법을 통해 가능하면 OS Version에 종속적이지 않는 방법으로 구현하는 것을 권장합니다.
(System Parameter 뿐만 아니라 기타 다른 API들 또한 .Net Framework에 포함되어 있습니다.)
지금부터 작성하는 내용은 .Net Framework 2.0 이상의 버전에 해당하는 내용이니 참고 하시기 바랍니다.
System.Environment
이름
설명
CommandLine
이 프로세스에 대한 명령줄을 가져옵니다.
CurrentDirectory
현재 작업 디렉터리의 정규화된 경로를 가져오거나 설정합니다.
ExitCode
프로세스의 종료 코드를 가져오거나 설정합니다.
HasShutdownStarted
런타임의 종료 여부 또는 현재 응용 프로그램 도메인의 언로드 여부를 나타내는 값을 가져옵니다.
MachineName
이 로컬 컴퓨터의 NetBIOS 이름을 가져옵니다.
NewLine
이 환경에 대해 정의된 줄 바꿈 문자열을 가져옵니다.
OSVersion
현재 플랫폼 식별자와 버전 번호가 들어 있는 OperatingSystem 개체를 가져옵니다.
ProcessorCount
현재 컴퓨터의 프로세서 수를 가져옵니다.
StackTrace
현재 스택 추적 정보를 가져옵니다.
SystemDirectory
시스템 디렉터리의 정규화된 경로를 가져옵니다.
TickCount
시스템 시작 이후 경과 시간(밀리초)을 가져옵니다.
UserDomainName
현재 사용자와 관련된 네트워크 도메인 이름을 가져옵니다.
UserInteractive
현재 프로세스가 사용자 대화형 모드로 실행되고 있는지 여부를 나타내는 값을 가져옵니다.
UserName
Windows 운영 체제에 현재 로그온한 사용자의 이름을 가져옵니다.
Version
런타임의 주 번호, 보조 번호, 빌드 번호 및 수정 번호를 설명하는 Version 개체를 가져옵니다.
WorkingSet
프로세스 컨텍스트에 매핑되는 실제 메모리의 크기를 가져옵니다.

System.Windows.Forms.SystemInformation
이름
설명
ActiveWindowTrackingDelay
활성 창 추적 지연을 가져옵니다.
ArrangeDirection
운영 체제에서 최소화된 창을 정렬하는 방향을 나타내는 값을 가져옵니다.
ArrangeStartingPosition
운영 체제에서 최소화된 창을 정렬하는 데 사용할 시작 위치를 나타내는 ArrangeStartingPosition 값을 가져옵니다.
BootMode
시스템 시작에 사용된 부팅 모드를 나타내는 BootMode 값을 가져옵니다.
Border3DSize
3차원 스타일 창 또는 시스템 컨트롤 테두리의 두께(픽셀 단위)를 가져옵니다.
BorderMultiplierFactor
창 크기 조정 테두리의 두께를 결정하는 데 사용되는 테두리 승수 요소를 가져옵니다.
BorderSize
2차원 스타일 창 또는 시스템 컨트롤 테두리의 두께를 픽셀 단위로 가져옵니다.
CaptionButtonSize
창의 제목 표시줄에 표시되는 단추의 표준 크기를 픽셀 단위로 가져옵니다.
CaptionHeight
창의 표준 제목 표시줄 영역 높이를 픽셀 단위로 가져옵니다.
CaretBlinkTime
캐럿 깜박임 시간을 가져옵니다.
CaretWidth
edit 컨트롤에 나타나는 캐럿의 너비를 픽셀 단위로 가져옵니다.
ComputerName
로컬 컴퓨터의 NetBIOS 컴퓨터 이름을 가져옵니다.
CursorSize
커서의 최대 크기를 픽셀 단위로 가져옵니다.
DbcsEnabled
운영 체제에서 DBCS(더블바이트 문자 집합) 문자를 처리할 수 있는지 여부를 나타내는 값을 가져옵니다.
DebugOS
USER.EXE의 디버그 버전이 설치되었는지 여부를 나타내는 값을 가져옵니다.
DoubleClickSize
운영 체제에서 두 번의 클릭을 "두 번 클릭(double-click)"으로 간주하도록 하기 위해 사용자가 두 번 클릭해야 하는 영역의 크기(픽셀 단위)를 가져옵니다.
DoubleClickTime
두 번 클릭(double-click)이 이루어지기 위해 첫 번째 클릭 이후 두 번째로 클릭할 때까지의 제한 시간을 밀리초 단위로 가져옵니다.
DragFullWindows
사용자가 전체 창 끌기를 활성화했는지 여부를 나타내는 값을 가져옵니다.
DragSize
마우스 단추를 누른 지점을 중심으로 하고 끌기 작업이 시작되지 않는 사각형의 너비와 높이를 가져옵니다.
FixedFrameBorderSize
캡션이 있으며 크기를 조정할 수 없는 창의 프레임 테두리 두께(픽셀 단위)를 가져옵니다.
FontSmoothingContrast
ClearType 다듬기에 사용되는 글꼴 다듬기 대비 값을 가져옵니다.
FontSmoothingType
현재의 글꼴 다듬기 형식을 가져옵니다.
FrameBorderSize
끌기로 크기 조정할 창 둘레에 그려지는 크기 조정 테두리의 두께를 픽셀 단위로 가져옵니다.
HighContrast
사용자가 내게 필요한 옵션 기능인 고대비 모드를 활성화했는지 여부를 나타내는 값을 가져옵니다.
HorizontalFocusThickness
시스템 포커스 사각형의 왼쪽 및 오른쪽 가장자리 두께를 픽셀 단위로 가져옵니다.
HorizontalResizeBorderThickness
크기를 조정 중인 창 둘레의 크기 조정 테두리 왼쪽 및 오른쪽 가장자리의 두께를 픽셀 단위로 가져옵니다.
HorizontalScrollBarArrowWidth
가로 스크롤 막대에 있는 화살표 비트맵의 너비(픽셀 단위)를 가져옵니다.
HorizontalScrollBarHeight
가로 스크롤 막대의 기본 높이(픽셀 단위)를 가져옵니다.
HorizontalScrollBarThumbWidth
가로 스크롤 막대에 있는 스크롤 상자의 너비(픽셀 단위)를 가져옵니다.
IconHorizontalSpacing
큰 아이콘 보기의 아이콘 정렬 셀 너비(픽셀 단위)를 가져옵니다.
IconSize
Windows 기본 프로그램 아이콘 크기(픽셀 단위)를 가져옵니다.
IconSpacingSize
큰 아이콘 보기로 아이콘을 정렬하는 데 사용되는 모눈 정사각형의 크기(픽셀 단위)를 가져옵니다.
IconVerticalSpacing
큰 아이콘 보기의 아이콘 정렬 셀 높이(픽셀 단위)를 가져옵니다.
IsActiveWindowTrackingEnabled
활성 창 추적 기능을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsComboBoxAnimationEnabled
콤보 상자에 슬라이드 방식으로 열기 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsDropShadowEnabled
그림자 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsFlatMenuEnabled
기본 사용자 메뉴가 기본 메뉴 모양인지 여부를 나타내는 값을 가져옵니다.
IsFontSmoothingEnabled
글꼴 다듬기를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsHotTrackingEnabled
메뉴 모음의 메뉴 이름과 같은 사용자 인터페이스 요소에 대해 핫 트래킹을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsIconTitleWrappingEnabled
아이콘 제목 줄바꿈 기능을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsKeyboardPreferred
사용자가 마우스보다 키보드를 우선적으로 사용하며 응용 프로그램에서 키보드 인터페이스를 표시하게 할 것인지 여부를 나타내는 값을 가져옵니다. 이 모드를 선택하지 않는 경우 일반적으로 키보드 인터페이스는 숨겨져 있습니다.
IsListBoxSmoothScrollingEnabled
목록 상자에 부드러운 스크롤 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsMenuAnimationEnabled
메뉴 페이드 또는 슬라이드 애니메이션 기능을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsMenuFadeEnabled
메뉴 페이드 애니메이션 기능을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsMinimizeRestoreAnimationEnabled
창 최소화 및 복원 애니메이션 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsSelectionFadeEnabled
선택 페이드 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsSnapToDefaultEnabled
기본 단추로 이동하는 기능을 사용하는지 여부를 나타내는 값을 가져옵니다.
IsTitleBarGradientEnabled
창 제목 표시줄에 그라데이션 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
IsToolTipAnimationEnabled
ToolTip 애니메이션을 사용하는지 여부를 나타내는 값을 가져옵니다.
KanjiWindowHeight
DBCS(더블바이트 문자 집합) 버전의 Windows 화면 맨 아래에 표시되는 간지 창의 높이(픽셀 단위)를 가져옵니다.
KeyboardDelay
키보드 반복 지연 설정을 가져옵니다.
KeyboardSpeed
키보드 반복 속도 설정을 가져옵니다.
MaxWindowTrackSize
캡션 및 크기 조정 테두리가 있는 창의 기본 최대 크기(픽셀 단위)를 가져옵니다.
MenuAccessKeysUnderlined
메뉴 선택키에 항상 밑줄을 표시하는지 여부를 나타내는 값을 가져옵니다.
MenuBarButtonSize
메뉴 모음 단추의 기본 너비(픽셀 단위)와 메뉴 모음의 높이(픽셀 단위)를 가져옵니다.
MenuButtonSize
메뉴 모음 단추의 기본 크기(픽셀 단위)를 가져옵니다.
MenuCheckSize
메뉴 확인 표시 영역의 기본 크기(픽셀 단위)를 가져옵니다.
MenuFont
메뉴에 텍스트를 표시하는 데 사용되는 글꼴을 가져옵니다.
MenuHeight
메뉴 한 줄의 높이(픽셀 단위)를 가져옵니다.
MenuShowDelay
마우스 커서가 하위 메뉴 항목 위에 있을 때 계단식 바로 가기 메뉴가 표시될 때까지의 시간(밀리초 단위)을 가져옵니다.
MidEastEnabled
운영 체제에서 히브리어 및 아랍어를 사용할 수 있는지 여부를 나타내는 값을 가져옵니다.
MinimizedWindowSize
최소화된 보통 창의 크기(픽셀 단위)를 가져옵니다.
MinimizedWindowSpacingSize
최소화된 창을 정렬할 때 최소화된 각 창에 할당되는 영역의 크기를 가져옵니다.
MinimumWindowSize
창의 최소 너비 및 높이(픽셀 단위)를 가져옵니다.
MinWindowTrackSize
창을 끌어서 크기를 조정하는 동안 창에 적용할 기본 최소 크기(픽셀 단위)를 가져옵니다.
MonitorCount
데스크톱에 있는 디스플레이 모니터의 수를 가져옵니다.
MonitorsSameDisplayFormat
모든 디스플레이 모니터가 같은 픽셀 색 형식을 사용하는지 여부를 나타내는 값을 가져옵니다.
MouseButtons
마우스에 있는 단추 수를 가져옵니다.
MouseButtonsSwapped
마우스 왼쪽 및 오른쪽 단추의 기능이 바뀌었는지 여부를 나타내는 값을 가져옵니다.
MouseHoverSize
마우스로 가리킴 메시지가 생성되기 전까지 마우스로 가리킴 시간 동안 마우스 포인터가 머물러 있어야 하는 사각형의 크기(픽셀 단위)를 가져옵니다.
MouseHoverTime
마우스로 가리킴 메시지가 생성되기 전까지 마우스로 가리킴 사각형 안에 마우스 포인터가 머물러 있어야 하는 시간(밀리초 단위)을 가져옵니다.
MousePresent
포인팅 장치가 설치되어 있는지 여부를 나타내는 값을 가져옵니다.
MouseSpeed
현재 마우스 속도를 가져옵니다.
MouseWheelPresent
마우스에 마우스 휠이 설치되어 있는지 여부를 나타내는 값을 가져옵니다.
MouseWheelScrollDelta
단일 마우스 휠 회전 증분에 대한 델타 값 크기를 가져옵니다.
MouseWheelScrollLines
마우스 휠이 회전될 때 스크롤할 줄 수를 가져옵니다.
NativeMouseWheelSupport
운영 체제에서 기본적으로 마우스 휠을 지원하는지 여부를 나타내는 값을 가져옵니다.
Network
현재 네트워크에 연결되어 있는지 여부를 나타내는 값을 가져옵니다.
PenWindows
Microsoft Windows for Pen Computing 확장이 설치되어 있는지 여부를 나타내는 값을 가져옵니다.
PopupMenuAlignment
해당 메뉴 모음 항목을 기준으로 정렬하는 데 사용되는 팝업 메뉴의 측면을 가져옵니다.
PowerStatus
현재 시스템 전원 상태를 가져옵니다.
PrimaryMonitorMaximizedWindowSize
기본 디스플레이에서 최대화된 창의 기본 크기(픽셀 단위)를 가져옵니다.
PrimaryMonitorSize
기본 디스플레이의 현재 비디오 모드 크기(픽셀 단위)를 가져옵니다.
RightAlignedMenus
드롭다운 메뉴가 해당 메뉴 모음 항목 오른쪽에 맞추어져 있는지 여부를 나타내는 값을 가져옵니다.
ScreenOrientation
화면의 방향을 가져옵니다.
Secure
이 운영 체제에 보안 관리자가 있는지 여부를 나타내는 값을 가져옵니다.
ShowSounds
응용 프로그램에서 청취 가능 형식의 정보를 나타낼 때 시각적 형식으로도 정보를 나타내도록 할지 여부를 나타내는 값을 가져옵니다.
SizingBorderWidth
크기를 조정 중인 창 둘레에 그려지는 크기 조정 테두리의 너비(픽셀 단위)를 가져옵니다.
SmallCaptionButtonSize
작은 캡션 단추의 너비(픽셀 단위)와 작은 캡션의 높이(픽셀 단위)를 가져옵니다.
SmallIconSize
작은 아이콘의 크기(픽셀 단위)를 가져옵니다.
TerminalServerSession
호출 프로세스가 터미널 서비스 클라이언트 세션에 연결되는지 여부를 나타내는 값을 가져옵니다.
ToolWindowCaptionButtonSize
작은 캡션 단추의 크기(픽셀 단위)를 가져옵니다.
ToolWindowCaptionHeight
도구 창 캡션의 높이(픽셀 단위)를 가져옵니다.
UIEffectsEnabled
UI(사용자 인터페이스) 효과를 사용하는지 여부를 나타내는 값을 가져옵니다.
UserDomainName
사용자가 속하는 도메인의 이름을 가져옵니다.
UserInteractive
현재 프로세스가 사용자 대화형 모드로 실행되고 있는지 여부를 나타내는 값을 가져옵니다.
UserName
현재 스레드와 연결된 사용자 이름을 가져옵니다.
VerticalFocusThickness
시스템 포커스 사각형의 위쪽 및 아래쪽 가장자리 두께(픽셀 단위)를 가져옵니다.
VerticalResizeBorderThickness
크기를 조정 중인 창 둘레의 크기 조정 테두리 위쪽 및 아래쪽 가장자리의 두께(픽셀 단위)를 가져옵니다.
VerticalScrollBarArrowHeight
세로 스크롤 막대에 있는 화살표 비트맵의 높이(픽셀 단위)를 가져옵니다.
VerticalScrollBarThumbHeight
세로 스크롤 막대에 있는 스크롤 상자의 높이(픽셀 단위)를 가져옵니다.
VerticalScrollBarWidth
세로 스크롤 막대의 기본 너비(픽셀 단위)를 가져옵니다.
VirtualScreen
가상 화면의 경계를 가져옵니다.
WorkingArea
화면의 작업 영역 크기(픽셀 단위)를 가져옵니다.

by 딸기아부지 | 2011/08/11 14:17 | 윈도우관련 | 트랙백
Windows Services in C#: Controlling Your Service from Another Application

Windows Services in C#: Controlling Your Service from Another Application (part 6)

If you’ve ever used SQL Server, you know it comes with a little control program that allows you to start and stop the SQL Server service. Wouldn’t it be cool if you could write a small program to do the same with your service? Well you can, and today we’ll learn how.

Before we begin, I made a few little tweaks to the TimeLoggerService source code that will make it a bit easier to work with, and implement some of the things we’ll want to do in our control program.

    public TimeLoggerService()

    {

      InitializeComponent();

      // Set the timer to fire every twenty seconds

      // (remember the timer is in millisecond resolution,

      //  so 1000 = 1 second. )

      _timer = new Timer(20000);

 

      // Now tell the timer when the timer fires

      // (the Elapsed event) call the _timer_Elapsed

      // method in our code

      _timer.Elapsed += new

        System.Timers.ElapsedEventHandler(_timer_Elapsed);

    }

 

    private void WriteToLog(string msg)

    {

      EventLog evt = new EventLog(“ArcaneTimeLogger”);

      string message = msg + “: “

        + DateTime.Now.ToShortDateString() + ” “

        + DateTime.Now.ToLongTimeString();

      evt.Source = “ArcaneTimeLoggerService”;

      evt.WriteEntry(message, EventLogEntryType.Information);

    }

 

    protected override void OnStart(string[] args)

    {

      _timer.Start();

      WriteToLog(“Arcane Start”);

    }

 

    protected override void OnStop()

    {

      _timer.Stop();

      WriteToLog(“Arcane Stop “);

    }

 

    // This method is called when the timer fires

    // it’s elapsed event. It will write the time

    // to the event log.

    protected void _timer_Elapsed(object sender, ElapsedEventArgs e)

    {

      WriteToLog(“Arcane Timer”);

    }

In the class constructor, the only change I made was to change the time from 60 seconds (60000 milliseconds) down to 20 seconds (20000 milliseconds). To be honest I got tired of waiting on it to log for my tests.

Next, I created a “WriteToLog” method that handles the actual writing of a message to the event log. This code is identical to what was previously in the timer_Elapsed event, except I take a passed in message and append the current date/time to the log. Note one other change, I modified it to use the LongTimeString instead of ShortTimeString, so I could get the seconds to display.

I then modified the OnStart and OnStop to log start and stop messages for me, which is probably a good idea for your service to do too. Finally I modified the _timer_Elasped event where I’d taken the WriteToLog code from, and made a call to our new method. OK, that takes care of changes to the windows service.

Now, let’s add a new project to our solution. In the Solution Explorer, right click on the solution name and pick Add Project, then pick Windows Application. Note that we could do this with a command line app or class library as well, but for this demo we’ll use a windows form. I gave my new app the imaginative name of “TimeLoggerManager”.

I renamed the Form1 to TLManager, and allowed VS to rename all the occurances of Form1 for me. I’m now going to add a few basic controls, one label (lblStatus), and two command buttons (btnStart and btnStop). I’m also going to add a timer control, tmrRefresh. Set the timer to enabled and pick a reasonable time, maybe every 10 or 15 seconds (10000 or 15000 in the Interval property, remember it gets set in milliseconds as well).

In order to use some of the classes we’ll need, we must set a reference to the System.ServiceProcess assembly. Right click on the TimeLoggerManager and Add Reference, then on the .Net tab scroll down to System.ServiceProcess, click on it and press OK.

Now switch to code view on the form, and in the using area add a “using System.ServiceProcess” reference.

The first thing we need to do is find out what the status is of the service event. To do this we’ll first get a reference to our service by creating a ServiceController object, note in the “new” area we have to pass in the name of our service in order to get a reference to it. Once our object is created, I’ll pass it to a method that will set everything up for the form.  

      ServiceController sc = new ServiceController(“ArcaneTimeLogging”);

      SetDisplay(sc);

Set Display is a custom method I wrote, here’s it’s code:

    private void SetDisplay(ServiceController sc)

    {

      sc.Refresh();

      if (sc.Status == ServiceControllerStatus.Stopped)

      {

        btnStop.Enabled = false;

        btnStart.Enabled = true;

        lblStatus.Text = “Stopped”;

      }

      if (sc.Status == ServiceControllerStatus.Running)

      {

        btnStart.Enabled = false;

        btnStop.Enabled = true;

        lblStatus.Text = “Running”;

      }

    }

The first thing called is sc.Refresh, this will cause the ServiceController to update all of the properties in our sc object with the correct values. Next I can query the Status property of our SC object, and set my command buttons and labels appropriately.

Starting and stopping our service is just as easy, all we have to do is create an instance of a service controller object, and then call it’s Start or Stop method.

    private void btnStart_Click(object sender, EventArgs e)

    {

      ServiceController sc = new ServiceController(“ArcaneTimeLogging”);

      sc.Start();

      btnStart.Enabled = false;

      btnStop.Enabled = true;

      lblStatus.Text = “Running”;

      sc.Refresh();

    }

 

    private void btnStop_Click(object sender, EventArgs e)

    {

      ServiceController sc = new ServiceController(“ArcaneTimeLogging”);

      sc.Stop();

      btnStop.Enabled = false;

      btnStart.Enabled = true;

      lblStatus.Text = “Stopped”;

      sc.Refresh();

    }

Because you can also start and stop the service from other locations, like VS or the MMC, it’s important to keep the display in sync. In the event for the timer, all we have to do is create another reference and pass it to the same SetDisplay method so everything stays in sync.

    private void tmrRefresh_Tick(object sender, EventArgs e)

    {

      ServiceController sc = new ServiceController(“ArcaneTimeLogging”);

      SetDisplay(sc);

    }

Go ahead and give it all a try. Start your service, then check it in the MMC. Use MMC to stop the service, then watch the app automatically update to reflect the status.

Tomorrow we’ll look at sending commands to our windows service, then to wrap up the series we’ll look at integrating the event log into our application. Stay tuned!

by 딸기아부지 | 2011/06/27 11:46 | 윈도우관련 | 트랙백
[펌] TDU2 사용 포트 / 방화벽에서 ... 막을 것
펌...
============이하============
저도 처음에 
NAT strict : UDP Blocked 가떠서 
한 5일 고생한거 같습니다.

윈도우 방화벽도 열어보고..
공식 홈페이지 가서 포트 8889 / 3478 열고 별 난리를 다 쳐봤지만 
되지 않더군요 

그러다 V3(백신프로그램) 방화벽에 가서 
TDU2.exe // UpLauncher.exe 
이 2가지를 차단 해제하니깐 서버 접속이 되었습니다.

참 허무하더군요.
저 같은 분이 있는것 같아서 도움을 드리기 위해 올려봤습니다.
영 안되시면 백신프로그램 방화벽을 아예 다 풀어보시는것도 ..
보안이 찝찝하다 싶으면 다 풀어버리는 건 비추입니다.
============이하============

by 딸기아부지 | 2011/05/22 18:59 | 기타잡기 | 트랙백
datagridview 사용 예제

http://ndolson.com/519  에서 퍼왔습니다.


=== 이하 ====



참고해서 프레임웍으로 만들어서 써야지 -_-;;


링크 : http://msdn.microsoft.com/ko-kr/library/y0wfd4yz.aspx
참고사이트: http://doki.springnote.com/pages/1342466
참고할것: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellformatting.aspx

예제 코드

using System;
using System.Windows.Forms;

public enum Title
{
    King,
    Sir
};

public class EnumsAndComboBox : Form
{
    private DataGridView dataGridView1 = new DataGridView();
    private BindingSource bindingSource1 = new BindingSource();

    public EnumsAndComboBox()
    {
        this.Load += new System.EventHandler(EnumsAndComboBox_Load);
    }

    private void EnumsAndComboBox_Load(object sender, System.EventArgs e)
    {
        // Populate the data source.
        bindingSource1.Add(new Knight(Title.King, "Uther", true));
        bindingSource1.Add(new Knight(Title.King, "Arthur", true));
        bindingSource1.Add(new Knight(Title.Sir, "Mordred", false));
        bindingSource1.Add(new Knight(Title.Sir, "Gawain", true));
        bindingSource1.Add(new Knight(Title.Sir, "Galahad", true));

        // Initialize the DataGridView.
        dataGridView1.AutoGenerateColumns = false;
        dataGridView1.AutoSize = true;
        dataGridView1.DataSource = bindingSource1;

        dataGridView1.Columns.Add(CreateComboBoxWithEnums());

        // Initialize and add a text box column.
        DataGridViewColumn column = new DataGridViewTextBoxColumn();
        column.DataPropertyName = "Name";
        column.Name = "Knight";
        dataGridView1.Columns.Add(column);

        // Initialize and add a check box column.
        column = new DataGridViewCheckBoxColumn();
        column.DataPropertyName = "GoodGuy";
        column.Name = "Good";
        dataGridView1.Columns.Add(column);

        // Initialize the form.
        this.Controls.Add(dataGridView1);
        this.AutoSize = true;
        this.Text = "DataGridView object binding demo";
    }

    DataGridViewComboBoxColumn CreateComboBoxWithEnums()
    {
        DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
        combo.DataSource = Enum.GetValues(typeof(Title));
        combo.DataPropertyName = "Title";
        combo.Name = "Title";
        return combo;
    }
    #region "business object"
    private class Knight
    {
        private string hisName;
        private bool good;
        private Title hisTitle;

        public Knight(Title title, string name, bool good)
        {
            hisTitle = title;
            hisName = name;
            this.good = good;
        }

        public Knight()
        {
            hisTitle = Title.Sir;
            hisName = "<enter name>";
            good = true;
        }

        public string Name
        {
            get
            {
                return hisName;
            }

            set
            {
                hisName = value;
            }
        }

        public bool GoodGuy
        {
            get
            {
                return good;
            }
            set
            {
                good = value;
            }
        }

        public Title Title
        {
            get
            {
                return hisTitle;
            }
            set
            {
                hisTitle = value;
            }
        }
    }
    #endregion

    [STAThread]
    public static void Main()
    {
        Application.Run(new EnumsAndComboBox());
    }

}






참고내용 

Writter by Youngil Kim, C#.NET Developer  

이번에는 WinForm에서 제공하는 DataGridView컨트롤을 사용해보는 컬럼을 마련해 보았습니다. 일단 간단하게 VS2005에서 Windows 응용프로그램 프로젝트를 하나 만들고 윈폼화면에 DataGridView컨트롤 배치시키고 마음에 드는 사이즈로 만드세요! ^^ 

여기서 사용하는 데이터베이스는 SQL Server 2005에서 새롭게 제공하는 Advanture Works 샘플DB의 Store테이블의 데이터를 가지고 설명하겠습니다.(다른 DB를 사용하시는 분들은 알아서 맞추시면 되요 ^^;) 데이터 연결된 소스부분은 같이 첨부한 샘플소스를 참고해주세요 ^^; 

<컨트롤 속성>

DataGridView ID: dbView 


1. 홀수행을 다른 색으로 보여주고 싶을 때

행마다 특정 배경색을 입혀보고 싶은 분들은 다음과 같이 구현하시면 됩니다. 일단 홀수행을 기준으로 설명하자면 AlternatiogRowsDefaultCellStyle속성에 BackColor를 선언하여 색상을 지정하시면 됩니다. 

dbView.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua; 


2. 여러개의 열이나 행을 선택하지 못하도록 막고 싶을 때

기본적으로 여러개의 열과 행을 선택할 수 있는데 이를 막고 한개의 열이나 한개의 행만 선택하도록 하고 싶을 때 다음과 같이 선언하면 됩니다. 

dbView.MultiSelect = false;
 

3. 행단위로 클릭하도록 만들고 싶을 때

기본적으로 열단위로 클릭하도록 처리되어 있는데 이를 행단위로 클릭할 수 있는 기능도 있습니다. 이 기능은 SelectionMode속성에 DataGridViewSelectionMode.FullRowSelect를 설정하면 간단하게 됩니다. 

dbView.SelectionMode = DataGridViewSelectMode.FullRowSelect;

 

참고로 DataGridViewSelectMode열거체이외의 값도 설정하여 열단위로 선택기능을 구현할 수 있고 열단위로 선택기능을 사용시 각 열에 대한 SortMode속성이 Automatic값(기본)으로 설정이 안되어 있으면 사용할 수 없습니다.
 

4. 행번호 보여주고 싶을 때

각 행의 행번호를 보여주고 싶을 때에는 행을 화면에 보여주는 타이밍인 RowPostPaint이벤트 타이밍에 그 행의 인덱스번호+1형태로 행헤더의 열 안에 넣어주면 끝납니다.

RowPostPaint이벤트핸들러의 2번째 파라미터인 DataGridViewRowPostPaintEventArgs 객체로부터 보여주기 위해 필요한 Graphics객체나 좌표값을 얻을 수 있습니다.

이하 e변수로 받을 수 있는 객체에 대해서 알아보면 다음과 같습니다. 

<DataGridViewRowPostPaintEventArgs 객체>
  * e.Graphics - Graphics객체
  * e.RowIndex - 표시중인 행번호 (0부터 시작하기 떄문에 +1필요) 
  * e.RowBounds.X 행헤더 열 왼쪽 위 X좌표
  * e.RowBounds.Y 행헤더 열 왼쪽 위 Y좌표
  * e.RowBounds.Height 행헤더 열높이
  * dbView.RowHeadersWidth 행헤더 셀 폭
  * dbView.RowHeadersDefaultCellStyle.Font 사용폰트
  * dbView.RowHeadersDefaultCellStyle.FontColor 폰트 색상
  
private void dbView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {

     // RowPointPaint 이벤트핸들러
     // 행헤더 열영역에 행번호를 보여주기 위해 장방형으로 처리
     Rectangle rect = new Rectangle(e.RowBounds.Location.X,

                         e.RowBounds.Location.Y,

                         dbView.RowHeadersWidth - 4,

                         e.RowBounds.Height);
     // 위에서 생성된 장방형내에 행번호를 보여주고 폰트색상 및 배경을 설정
     TextRenderer.DrawText(e.Graphics,

                         (e.RowIndex + 1).ToString(), 

                         dbView.RowHeadersDefaultCellStyle.Font,

                         rect,  

                         dbView.RowHeadersDefaultCellStyle.ForeColor,

                         TextFormatFlags.VerticalCenter | TextFormatFlags.Right);

}

 

5. 특정 행이나 열을 고정시키고 스크롤하지 못하도록 막고 싶을 때

여기서는 2번째 열을 고정시킨 경우를 보여주고 있는데 그리드를 옆으로 스크롤 할 경우 3번째 열보다 우측의 스크롤이 나오고 1번째열과 2번째열은 고정된 형태를 보여줍니다. 

- Frozen 속성 : 열 고정시키기 위한 속성으로 이를 고정시키기 위한 열을 지정하고 true값을 선언하면 해당 열의 좌측 열은 전부 고정되어 스크롤 할 없게 됩니다. 

dbView.Columns[1].Frozen = true; 

- DividerWidth 속성 : 구분선 폭 변경을 할 때 사용하는 속성으로서 이를 통해서 2번째열과 3번째열 사이 구분선을 약간 두껍게 표현하여 보다 직관적으로 구분할 수 있습니다. 

dbView.Columns[1].DividerWidth = 3;

 

6. 그리드 실행될 때 기본 열이 선택된 모습을 보여주고 싶지 않을 때

아주 간단하게 속성하나만 선언하면 되는데 이때 주의해야할 점은 폼_Load이벤트핸들러에서는 효과가 없다는 것입니다. 어느 열도 선택되지 않는 상태로 보여주기 위해서는 폼이 표시된 이후 한번만 발생하는 폼_Shown 이벤트핸들러에서 선언해주는 것이 좋습니다. 

        private void Form1_Shown(object sender, EventArgs e)
        {
            //6. 그리드 실행될 때 기본 열이 선택된 모습을 보여주고 싶지 않을 때
            dbView.CurrentCell = null;
        }

 

7. 특정값을 가진 열을 좀 다르게 보여주고 싶을 때

특정값을 가진 열을 좀더 강조하여 보여주고 싶은 경우가 종종 생깁니다. 이럴 때 유용한 것으로 예제에서는 Bike란 단어가 포함된 열인 경우 빨간색으로 글씨를 보여주도록 설정하였습니다.

특히, 개별적인 열에 대해서 보여주기 위해서는 폼_CellFormating이벤트핸들러를 이용하면 될것같습니다. 본래 이 이벤트핸들러는 특정값을 가진 열의 독립적인 서식을 적용하기 위한 것으로 열 스타일만 변경할 수 있습니다.

CellFormmating이벤트핸들러의 2번째파라미터로 받는 DataGridViewCellFormattingEventArgs객체로부터 그 열의 현재 스타일이나 열의 값을 얻거나 설정할 수 있습니다. 즉, 이것을 통해 열의 값을 확인하고 그 스타일을 변경하는 형태로 개발을 해보려고 합니다. 또한, 이벤트 발생시 열위치는 ColumnIndex속성과 RowIndex속성으로 알 수 있습니다. 

private void dbView_CellFormatting(object sender,

DataGridViewCellFormattingEventArgs e) {
{
      // 7. 특정값을 가진 열을 좀 다르게 보여주고 싶을 때
      if (e.ColumnIndex == 1)
      {
            if (e.Value != null)
            {
                 string text = e.Value.ToString();
                 if (text.Contains("Bike"))
                 {
                      e.CellStyle.ForeColor = Color.Red;
                      e.CellStyle.SelectionForeColor = Color.Red;
                  }
              }
         }
  }

 

8. 헤더열이나 헤더행의 색을 변경하고 싶을 때

헤더행과 헤더열의 색을 변경하고싶은 경우에는 ColumnHeadersDefaultCellStyle속성과 RowHeadersDefaultCellStyle속성을 사용하면 괜찮을 것같습니다. 

dbView.ColumnHeadersDefaultCellStyle.BackColor = Color.RosyBrown;
dbView.RowHeadersDefaultCellStyle.BackColor = Color.SeaGreen; 

단, 위와 같이 선언하여도 그것이 사용할 수 없는 경우가 있는데 이것은 애플리케이션이 적용하고 있는 Windows XP의 Visual 스타일을 우선적으로 사용하기 때문인데 이 코드는 윈폼을 만들 때 자동으로생성하기 때문에 Application클래스의 EnableVisualStyles메소드를 호출합니다. 

dbView.EnableHeadersVisualStyles = false; 

그외 열과 행의 사이에 있는 선스타일을 변경할 수 있는데 다음과 같이 선언하게 되면 한개의 라인으로 보여주게 됩니다. 

dbView.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
dbView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;

 

9. 선택한 행이나 열에 대한 값을 확인하고 싶을 때

보통 특정 행을 추가하거나 삭제하고 편집도 하는데 이럴 때 선택된 행이나 열에 대해서 어떤 조작을 하는 경우도 많습니다. 그래서 이번에는 이를 간단하게 처리하는 방법에 대해서 정리해보았습니다. 이 부분에 대한 것을 사용형태만 설명하고 넘어가겟습니다. 

아래에서 설명한 것들중에서 같은 클래스명이나 속성명이 Row가 들어가거나 Column이란 단어로 비교되는 것을 알 수 있는데 이것에 의해 열에 대한 행과 똑같은 조작을 할 수 있다는 것을 알 수 있습니다. 

- 선택된 열 얻기 : SelectedCells 속성

현재 선택된 열은 SelectedCells속성으로 얻을 수 있고 그리드에서 여러개의 열을 동시에 선택할 수 있기 때문에 이 속성은 DataGridViewSelectedCellCollection클래스 객체로 되어 잇습니다. 여기서는 간단하게 하나의 열을 조작할 경우에 사용되는 형태를 보여줍니다. 

foreach (DataGridViewCell cell in dbView.SelectedCells) { } 

선택된 열 갯수 얻기을 얻어 위에서 선택된 열을 얻을 수 있는 방법도 있습니다.

 SelectedCells.Count

for(int i=0; i<dbView.SelectedCells.Count; i++) { } 

또한 MultiSelect속성을 false를 설정한 것은 사용자가 여러개의 행/열을 선택할 수 있도록 할 수 있습니다. 

- 선택된 행 얻기 : SelectedRows 속성

행을 선택하여 행정보를 얻는 경우에 필요한 것으로 DataGridViewRow클래스의 객체의 컬렉션은 Selectedows속성으로 얻을 수 있습니다. 

foreach(DataGridViewRow row in dbView.SelectedRows) { } 

- 특정 셀이나 행이 선택되었는지 확인하는 경우 : Selected 속성

셀이 선택되었다면 true, 셀이 선택되지 않았다면 false로 결과를 보내줍니다. 

dbView[x,y].Selected; 

특정 행이 선택되었는지 확인하는 경우 

dbView.Rows[n].Selected; 

- 선택된 행이나 열 설정

데이터 새로고침등의 이벤트로 인해 데이터를 새롭게 보여줄때 현재 위치를 나타내고 싶은 경우에 필요한 것으로 (x,y)위치에 있는 열을 선택한 상태로 두고 싶다면 다음과 같이 선언합니다. 

dbView[x,y].Selected = true; 

n행의 행을 선택한 상태로 두고 싶은 경우에는 아래와 같이 선언합니다. 

dbView.Rows[n].Selected = true; 

- 모든 선택된 열을 지울 때 : ClearSelection 메소드

 

10. 열에 보여지는 문자열을 여러행으로 보여주고 싶을 때

열에 표시되는 문자열이 길게 되면 한줄로 보여주지만 오버되면 잘려서 안보여줍니다. 이는 열스타일의 WrapMode속성을 DataGridViewTriState.True(그외 False, NotSet)로 설정하여 셀크기안에서 오버되면 여러행으로 해당 텍스트등을 모두 보여줍니다.

그리드안의 모든 열을 여러행을 보여주고 싶다면, DefaultCellStyle속성의 WrapMode속성에 DataGridViewTriState.True를 설정하는 것을 권장합니다. 이렇게하면 정말 간단하게 구현이 됩니다. ^^

또한, 다음줄로 넘어간 문자열이 발생하면 행의 높이는 자동으로 조절되는데 AutoSizeRowMode속성에 DataGridViewAutoSizeRowsMode.AllCells를 설정할 것을 권장합니다. 이상 이 두가지를 정리하면 다음과 같습니다. 

dbView.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dbView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

 

11. 맨 밑까지 스크롤하고 싶을 때

보통 맨 밑에 있는 행을 합계로 보여주거나 응용프로그램 실행시 곧바로 사용자가 새 행을 추가할 있도록 하는 경우가 있는데 이럴때 그리드 맨밑까지 스크롤을 가볍게 해줄 필요가 있습니다. 열단위 표시를 스크롤하기 위한 속성이 3가지가 있는데 다음과 같습니다. 

<속성>

FirstDisplayedCell 그리드 왼쪽 위에 표시된 열 얻기/설정

FirstDisplayedScrollingColumnIndex 그리드에 표시된 처음 열 얻기/설정

FirstDisplayedScrollingRowIndex 그리에 표시된 처음 행 얻기/설정 

예를 들어 [2,15]의 위치에 있는 열을 FirstDisplayedCell속성으로 설정하면 [2,15]위치의 열에 왼쪽위로 그리드가 스크롤된 상태로 보여집니다. 

dbView.FirstDisplayedCell = dbView[2,15]; 

마지막 행을 표시하기 위해 그리드 맨밑까지 스크롤시키려면 FirstDisplayedScrollingRowIndex속성을 이용하길 권장합니다. 

dbView.FirstDisplayedScrollingRowIndex = dbView.Rows.Count - 1;

 

12. 오토컴플릿 기능을 사용하고 싶을 때

텍스트박스 열은 열 편집 및 새 행을 추가시 텍스트박스를 사용합니다. 이럴때 열편집시 오토컴플릿 기능을 사용할 수 있다는 점입니다.

이는 열이 편집상태가 될 때 발생하는 EditingControlShowing이벤트핸들러가 발생할 때 보여주고 있는 텍스트박스 객체를 얻어 오토컴플릿에 필요한 속성을 설장하는 형태입니다.

실제 이 텍스트박스는 DataGridViewTextBoxEditingControl 클래스의 인스턴스를 만들어 TextBox클래스의 파생클래스로서 TextBox형으로 케스팅합니다.

이렇게 예고로 내놓은 코드는 모든 텍스트박스에 대한 오토컴플릿기능을 설정하고 있기 때문에 어느 열을 사용하더라도 오토컴플릿기능이 작동되며 특정열만 오토컴플릿 기능을 지정할 수도 있습니다. 이 예제에서는  

 private void dbView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
 {
        TextBox tb = e.Control as TextBox;
        if (tb == null)
        {
             return;
         }
        if (dbView.CurrentCell.ColumnIndex == 1)
        {
             tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
             tb.AutoCompleteSource = AutoCompleteSource.AllSystemSources;
         }
         else
         {
             tb.AutoCompleteMode = AutoCompleteMode.None;
         }
  }  

 

13. 열안에 문자열 선택하고 싶을 때

열 안에의 문자열을 선택하여 처리하고 싶다면 BeginEdit메소드를 사용하는 것을 권장합니다. 이 이름처럼 열을 편집하기 위한 것으로 파라미터값을 true로 선언하면 열 안의 문자열이 선택된 상태로 편집할 수 있습니다. 만약 false로 선언하면 커서가 문자열은 선택하지 않고 문자열끝에 커서가 있는 상태로 조작을 할 수 있습니다. 

 // 폼_Load이벤트핸들러가 BeginEdit를 호출할 경우 폼을 먼저 표시할 필요가 있음
 this.Show();
 // 2행 1열 열을 현재 열로 지정
 dbView.CurrentCell = dbView[0, 1];
 // 현재 열을 편집상태로
 dbView.BeginEdit(true);

 

14. 왼쪽 윗 빈 열에 값 설정하고 싶을 때

왼쪽 맨 윗열은 항상 빈 여백의 열로 남아 있는데 여기에 특정한 표시를 나타내기 위해 값을 넣거나 열 스타일을 변경할 수 있습니다.

이 빈열은 DataGridView컨트롤의 TopLeftHeaderCell속성으로 접근할 수 있고 이 속성값은 헤더 행이나 헤더 열과 동일한 DataGridViewHeaderCell클래스의 객체입니다. 일반적인 열을 나타내는 DataGridViewCell클래스를 상속받은 클래스입니다. 

dbView.TopLeftHeaderCell.Value = "매장";

 

15. 오른쪽버튼 클릭시 열 선택을 할 수 있도록 하고 싶을 때

기본적으로 마우스 오른쪽버튼으로 클릭시 어떠한 조작도 제어되지 않습니다. 그래서 간단하게 클릭시 열을 선택할 수 있도록 하는 방법을 추가해보고자 합니다.

이는 CellMouseClick이벤트핸들러를 생성하여 열을 클릭시 Control클래스로 정의되어 있는 MouseClick이벤트가 추가되어 CellMouseClick이벤트핸들러가 발생하는 형태입니다. 이 이벤트핸들러의 파라미터로는 클릭된 열의 행번호와 열번호를 얻을 있어 클릭되어 진 열을 간단하게 접근하실 수 있습니다.

여기서 보여주는 스타일은 이벤트핸들러를 통해 클릭된 열의 선택상태를 알려주는 것을 아주 간단합니다. 

 private void dbView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
      //오른쪽 버튼 클릭인가?
      if (e.Button == MouseButtons.Right) {
           // 헤더 이외의 열
          if (e.ColumnIndex >= 0 && e.RowIndex >= 0) {
               // 오른쪽 버튼 클릭된 열
               DataGridViewCell cell = dbView[e.ColumnIndex, e.RowIndex];
               cell.Selected = !cell.Selected; // 선택상태 반전
           }
      }

  }  

한가지더 알려드리자면, 두번째 파라미터 DataGridViewCellMouseEventArgs클래스는 MouseClick이벤트핸들러의 파라미터인 MouseEventArgs클래스의 파생클래스입니다. 이 클래스는 마우스의 위치나 클릭된 버튼 종류를 알려주며 클릭된 열의 행번호와 열번호를 리턴해주는 RowIndex속성과 ColumnIndex속성이 추가되어 있고 헤더용 열이나 행이 클릭된 경우 속성은 -1로 처리됩니다.

 

16. 행 삭제시 확인메세지를 보여주고 싶을 때

행을 선택하고 Del키를 누르면 행을 삭제할 수 있습니다. 이럴 때 행의 삭제시 확인 메세지박스를 보여주는 형태를 구현하고 싶은 분들이 있을 것입니다. 이를 한번 구현해보이도록 하겠습니다.

DataGridView컨트롤에서는 행이 삭제될 때 UserDeletingRow이벤트핸들러가 발생합니다. 따라서 이 타이밍에 확인 메세지박스를 보여주는 것을 좋을 것같습니다. 그리고 한가지 팁으로 여러개의 행을 선택하고 Del키를 누르면 선택되어 있는 각 행별로 UserDeletingRow이벤트핸들러가 발생합니다.

또한 이 UserDeletingRow이벤트핸들러의 두번째 파라미터는 DataGridViewRowCancelEventArgs객체의 Cancel속성을 true로 설정하여 행삭제를 취소할 수 있습니다. 

private void dbView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) {
       if (MessageBox.Show("삭제하시겠습니까?",

                                 "지정한 행삭제",

                                 MessageBoxButtons.YesNo) == DialogResult.No)
       {
             e.Cancel = true; //삭제 취소
       }
 }  

 

17. 열 순서를 마음대로 바꾸고 싶을 때

가끔 고객의 요구로 인해 열을 사용자가 원하는 순서대로 배치하고 싶은 경우가 나옵니다. 이럴때 이런 기능을 모르면 대략 난감했죠 ㅜ_ㅜ; 근데 DataGridView에서는 간단하게 되네요 ^^; 보통 열 순서변경은 마우스로 열 헤더를 드래그&드롭하여 처리할 수 있습니다.

AllowUserToOrderColumns속성을 true로 하면 간단하게 끝납니다. ㅡ_ㅡ;;; 

dbView.AllowUserToOrderColumns = true; 

이상 제가 현재까지 알아낸 DataGridView컨트롤의 몇가지 기능을 간단하게 샘플로 만들어보았습니다. 나중에 색다른 것을 발견하면 추가하도록 할께요 ^^

풀소스는 다운로드받으시면 됩니다. ^^;

  - 소스는 아래의 출처 링크를 따라가세요 -

by 딸기아부지 | 2011/05/11 09:59 | 윈도우관련 | 트랙백
Fonera FON공유기 reset방법

Fonera

Factory reset
  • Unplug the Ethernet cable from the La Fonera.
  • Press the reset button located beneath the Fonera and hold it down for 15 to 20 seconds (no more). Use a pen or a paper clip to do so.
  • The original firmware will be loaded from a second storage area inside the Fonera. This process takes a couple of minutes to complete. Do not switch off the Fonera during this process.
  • Now, the Fonera is back to its default factory configuration: username/password of the Management console are admin/admin, the WPA key is the serial number (S/N: on the sticker beneath the Fonera) and the SSIDs are called 'MyPlace' and 'FON_AP'
  • Check if you can connect to 'MyPlace' wireless signal and if you can access the Management Console at http://192.168.10.1Check if everything is back to its default value, so you can see whether or not the reset has been successful.
  • Power off the Fonera, and plug it again to the Ethernet cable providing internet access.
  • Switch on the Fonera. As it is running with the default firmware it will download the latest firmware version as soon the internet connection is established. The update can take up to 45 minutes. No matter what, do not disconnect power cable while updating it would damage the Fonera.
  • During the update the WLAN and Internet LEDs will switch on and off a couple of times. The wireless signals may appear sometimes, if you are able to connect to them you might experience disconnections.
  • Once this process ends, both signals will appear continuously and you will be able to connect to both of them.



lafonera fon 공유기 벽돌 복구 프로그맴


될지 안될지는 모름.

< 필요한 프로그램 >

http://www.winpcap.org/    winpcap 프로그램이 설치되어 있어야 정상 작동함.


by 딸기아부지 | 2011/04/15 10:20 | 기타잡기 | 트랙백


< 이전페이지 다음페이지 >