728x90
728x90
SMALL

분류 전체보기 211

[C#] Get MAC address

/// /// 맥주소를 가져오는 함수/// /// 모든 MAC 주소를 구할 것인지의 여부 /// MAC 주소 목록 static public List> GetMacAddress(bool isAll = false) { try { NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); if (nics != null && nics.Count() > 0) { List> aMAC = new List>(); /// KeyValuePair foreach (NetworkInterface adapter in nics) { PhysicalAddress addr = adapter.GetPhysicalAddress(); string sAddr = addr..

유용한 정보 21:36:35

[C#] Import Excel File To DataGridView

/// /// Import Excel File To DataGridView /// /// DataGridView Control /// Excel File Path /// if first row in excel is header is then yes else no /// 엑셀파일의 버전이 2003보다 큰지의 여부 /// 성공하면 에러메세지가 없고 그렇지않으면 발생한 에러 메세지를 반환함 string GridViewExcel(Systehttp://m.Windows.Forms.DataGridView grid, string sFilePath, string sSheetName = "Sheet1" , string sFirstRowHeader = "no", bool isExcelFileVersion2003 = f..

유용한 정보 21:33:29

[C#] Excel to PrintPreview

/// /// 엑셀파일을 미리보기한다. /// /// 엑셀파일의 경로 /// 성공하면 에러메세지가 없고 그렇지않으면 발생한 에러 메세지를 반환함 string ExcelToPrintPreview(string sFilePath) { string sErrorMsg = string.Empty; Excel.Application xlApp = null; Excel._Workbook wb = null; Excel.Worksheet ws = null; try { xlApp = new Excel.Application(); //excelApp.ActivePrinter = PrinterSettings.InstalledPrinters[3]; wb = xlApp.Workbooks.Add(sFilePath); if (wb =..

유용한 정보 21:31:36

[C#] Excel To Printer

/// /// 엑셀파일을 출력한다. /// /// 엑셀파일의 경로 /// 엑셀파일의 Sheet Name /// 프린터명 /// 성공하면 에러메세지가 없고 그렇지않으면 발생한 에러 메세지를 반환함 string ExcelToPrint(string sFilePath, string sSheetName = "", object printer = null) { string sErrorMsg = string.Empty; Excel.Application excelApp = new Excel.Application(); Excel.Workbooks wbs = excelApp.Workbooks; Excel._Workbook wb = null; Excel.Worksheet ws = null; try { excelApp.Di..

유용한 정보 21:29:51

[C#] 문자열을 속성으로 갖는 클래스 만들기

1. 소스using System.Reflection; /// /// 문자열을 속성으로 갖는 클래스 /// public class StringValue : System.Attribute { private string _value; /// 문자열 속성값 /// /// 속성값을 설정한다. /// /// 속성값 public StringValue(string value) { _value = value; } /// /// 속성값을 가져온다. /// public string Value { get { return _value; } } } /// /// 자료형 enum에 문자열을 사용할 수 있게 하는 클래스 /// public static class StringEnum { /// /// enum에 Str..

유용한 정보 05:34:01

[C#] 컨트롤에 들어갈 문자열의 폭과 높이 구하기

1. 소스/// /// 컨트롤에 들어갈 문자열의 폭과 높이를 구한다. /// /// 문자열 /// 컨트롤 /// 폭과 높이 static public SizeF GetStringSize(string str, Control ctrl) { try { float wi = float.MinValue, hi; Font font = ctrl.Font; Bitmap tmpBit = new Bitmap(1, 1); Graphics graphic = Graphics.FromImage(tmpBit); Brush TextColor = Brushes.Black; graphic.DrawString(str, font, TextColor, new PointF(0, 0), StringFormat.GenericDefault); va..

유용한 정보 05:21:33

[C#] 컨트롤에 들어갈 문자열에서 가장 큰 폭과 높이 구하기

1. 소스/// /// 컨트롤에 들어갈 문자열에서 가장 큰 폭과 높이를 구한다. /// /// 문자열 /// 컨트롤 /// 폭과 높이 static public SizeF GetMaxSize(IEnumerable strings, Control ctrl) { try { float wi = float.MinValue, hi = 0; foreach (string v in strings) { SizeF size = GetStringSize(v, ctrl); hi += size.Height; if (size.Width > wi) wi = size.Width; } return new SizeF(wi, hi); } catch (Exception ex) { KLog.Write(ex.ToString()); } retu..

유용한 정보 05:18:43
728x90
728x90
LIST