Posted
Filed under C#

[원문] : http://www.csharphelp.com/2006/06/an-overview-of-link-label-in-c/

Introduction:

The LinkLabel control exhibits links to otherobjects, such as files or Web pages. Class LinkLabel is derived fromclass Label and therefore inherits all of class Label�s functionality.A LinkLabel looks as underlined text. When the mouse moves above thelink, the pointer modify to a hand. This is alike to the behavior of ahyperlink in a Web page. The link can change color to indicate whetherthe link is new, visited or active. When clicked, the LinkLabelgenerates a LinkClicked event.

Class LinkLabel :

Class LinkLabel is derived from class Label and therefore inherits all ofclass Label�s functionality. Hand image displays when mouse moves over LinkLabel.

Some common Properties of LinkLabel:

ActiveLinkColor – Denotes the color of the active link when clicked. Default is red.LinkColor – Denotes the original color of every links prior to they have been visited. Default is blue.
Links – Lists the LinkLabel Link objects, which are the links enclosed in the LinkLabel.
LinkVisited – If True, link appears as though it were visited (itscolor is changed to that specified by property VisitedLinkColor).
Text – Denotes the text to show on the control.
VisitedLinkColor – Denotes the color of visited links. Default is purple.
LinkArea – Denotes which part of text in the LinkLabel is treated as element of the link.
LinkBehavior – Denotes the link�s behavior, for example how the link come into view when the mouse is positioned over it.
LinkClicked – Generated when link is clicked.

Now let us see the usage of LinkLabel control with an example:
In this example I place a LinkLabel control with the text "To know C# -visit www.csharpheaven.com – Click Here!" and provide a link to aportion of the text. So that when clicked, the LinkLabel generates aLinkClicked event.

The Example:

using System;
using System.Drawing;
using System.ComponentModel;
using System.WinForms;
public class LinkLabel : System.WinForms.Form {
private System.WinForms.LinkLabel linkLabel1;

public LinkLabel() {

InitializeComponent();

}

public override void Dispose() {
base.Dispose();
}

public static void Main(string[] args) {
Application.Run(new LinkLabel());}
private void InitializeComponent()
{
this.linkLabel1 = new System.WinForms.LinkLabel();
linkLabel1.Text = "To know C# – visit www.csharpheaven.com – Click Here!";
linkLabel1.Size = new System.Drawing.Size(168, 56);
linkLabel1.LinkColor =
(System.Drawing.Color)System.Drawing.Color.FromARGB((byte)128,(byte)255, (byte)255);
linkLabel1.LinkArea = new System.Drawing.Point(42, 11);
linkLabel1.ForeColor = System.Drawing.Color.Maroon;
linkLabel1.Font = new System.Drawing.Font("Times New Roman", 10f,
System.Drawing.FontStyle.Bold);
linkLabel1.TabIndex = 0;
linkLabel1.TabStop = true;
linkLabel1.Location = new System.Drawing.Point(8, 16);
linkLabel1.LinkClick += new System.EventHandler(linkLabel1_LinkClicked);
this.Controls.Add(linkLabel1);
this.BackColor =
(System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)128, (byte)128);
}
protected void linkLabel1_LinkClicked(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("IExplore"," http://www.csharphelp.com");

}

}

Here the above program is written by hand (Adding LinkLabelcontrol to a form programmatically)

The program below is the code generated by the WINDES.exe.

// Win32Form1.cs
namespace Win32Form1Namespace {

using System;
using System.Drawing;
using System.ComponentModel;
using System.WinForms;

/// <summary>
/// Summary description for Win32Form1.
/// </summary>
public class Win32Form1 : System.WinForms.Form {

/// <summary>
/// Required by the Win Forms designer
/// </summary>
private System.ComponentModel.Container components;
private System.WinForms.LinkLabel linkLabel1;

public Win32Form1() {

// Required for Win Form Designer support
InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

}

/// <summary>
/// Clean up any resources being used
/// </summary>
public override void Dispose() {
base.Dispose();
components.Dispose();
}

/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args) {
Application.Run(new Win32Form1());
}

/// <summary>
/// Required method for Designer support – do not modify
/// the contents of this method with an editor
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.linkLabel1 = new System.WinForms.LinkLabel();

//@design this.TrayHeight = 0;
//@design this.TrayLargeIcon = false;
//@design this.TrayAutoArrange = true;
linkLabel1.Text = "To know C# – visit www.csharpheaven.com – Click Here!";
linkLabel1.Size = new System.Drawing.Size(184, 56);
linkLabel1.LinkColor = System.Drawing.Color.Teal;
linkLabel1.LinkArea = new System.Drawing.Point(42, 11);
linkLabel1.ForeColor = System.Drawing.Color.Maroon;
linkLabel1.Font =
new System.Drawing.Font("Times New Roman", 10f, System.Drawing.FontStyle.Bold);
linkLabel1.TabIndex = 0;
linkLabel1.DisabledLinkColor = System.Drawing.Color.Yellow;
linkLabel1.TabStop = true;
linkLabel1.Location = new System.Drawing.Point(8, 16);
linkLabel1.BackColor =
(System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)192, (byte)128);
linkLabel1.LinkClick += new System.EventHandler(linkLabel1_LinkClick);

this.Text = "Win32Form1";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.KeyPreview = true;
this.TransparencyKey = System.Drawing.Color.White;
this.BackColor =
(System.Drawing.Color)System.Drawing.Color.FromARGB((byte)255, (byte)128, (byte)128);
this.ClientSize = new System.Drawing.Size(272, 149);
this.Click += new System.EventHandler(Win32Form1_Click);

this.Controls.Add(linkLabel1);
}
protected void Win32Form1_Click(object sender, System.EventArgs e)
{

}
protected void linkLabel1_LinkClick(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("IExplore", "http://www.csharphelp.com" );

linkLabel1.LinkVisited = true;
}

}
}

2010/04/06 20:18 2010/04/06 20:18
Posted
Filed under C#
[원문] - http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=320

<%@ Page language="C#" debug="true" %>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
Response.ContentType="application/zip";
Response.AppendHeader("Content-Disposition","attachment; filename=myzipfile.zip");
Response.WriteFile(@"c:\inetpub\wwwroot\myzipfile.zip");
Response.Flush();
}
</script>

N.B. Reader Shaun College added the following to chop off the extra junk that may be sent by the ASP.NET runtime along with your file:

Response.AddHeader ("Content-Length", FileSize.ToString());
2010/04/02 09:18 2010/04/02 09:18
Posted
Filed under C#

using System;
using System.Windows.Forms;
using System.Drawing;

class TimerDemo:Form
{
Timer Clock;
Label lbTime=new Label();

public TimerDemo()
{
Clock=new Timer();
Clock.Interval=1000;
Clock.Start();
Clock.Tick+=new EventHandler(Timer_Tick);

this.Controls.Add(lbTime);
lbTime.BackColor=Color.Black;
lbTime.ForeColor=Color.Red;
lbTime.Font=new Font("Times New Roman",15);
lbTime.Text=GetTime();
}

public string GetTime()
{
string TimeInString="";
int hour=DateTime.Now.Hour;
int min=DateTime.Now.Minute;
int sec=DateTime.Now.Second;

TimeInString=(hour < 10)?"0" + hour.ToString() :hour.ToString();
TimeInString+=":" + ((min<10)?"0" + min.ToString() :min.ToString());
TimeInString+=":" + ((sec<10)?"0" + sec.ToString() :sec.ToString());
return TimeInString;
}

public void Timer_Tick(object sender,EventArgs eArgs)
{
if(sender==Clock)
{
lbTime.Text=GetTime();
}
}

public static void Main()
{
Application.Run(new TimerDemo());
}
}

2010/01/08 14:22 2010/01/08 14:22
Posted
Filed under C#
DateTime.Now.ToShortDateString().Replace("-", "");
2009/11/26 11:12 2009/11/26 11:12
Posted
Filed under C#
<pre>
// 프로그램 시작시간
DateTime startTime = DateTime.Now;

// 1. 현재시간
DateTime now;
now = DateTime.Now;

Console.WriteLine(now); // 현재시간 전체
Console.WriteLine(now.Year); // 현재 년도
Console.WriteLine(now.Month); // 현재 달
Console.WriteLine(now.Day); // 현재 일
Console.WriteLine(now.DayOfWeek); // 현재 주
Console.WriteLine(now.DayOfYear); // 1년중 몇일째인지
Console.WriteLine(now.TimeOfDay); // 금일 자정부터 몇시간
Console.WriteLine(now.Hour); // 시간
Console.WriteLine(now.Minute); // 분
Console.WriteLine(now.Second); // 초
Console.WriteLine(now.Millisecond); // 1000분의 1초

Console.WriteLine(now.Ticks); // 1000분의 1초

// 2. 임의시간 설정
DateTime birthday;
birthday = DateTime.Parse("2009년8월9일"); // 시분초 미지정시 자정으로
birthday = DateTime.Parse("2009/08/09");

Console.WriteLine(birthday);

DateTime xmas;
xmas = new DateTime(2008, 12, 25, 0, 0, 0);

Console.WriteLine(xmas);

// 3. 연산

// 3.1 오늘 + 100일
now = DateTime.Now;
DateTime result = now.AddDays(100); // 각 단위별 add메소드가 존재 MSDN참고

Console.WriteLine(result);

// 3.2 크리스마스까지 남은 날
TimeSpan result2 = xmas - now;
Console.WriteLine(result2);
Console.WriteLine(result2.Days); // NNN일 (내림표현)
Console.WriteLine(result2.TotalDays); // NNN.NNNNNNN일 (더정확)

// 3.3 오늘 - 100일
Console.WriteLine(now - TimeSpan.FromDays(100));
Console.WriteLine(now.AddDays(-100));

// 4. 날짜시간 출력형식 지정
Console.WriteLine(now.ToLocalTime()); // 2008-08-08 오전 10:31:25

Console.WriteLine(now.ToLongDateString()); // 2008년 8월 8일 금요일
Console.WriteLine(now.ToShortDateString()); // 2008-08-08

Console.WriteLine(now.ToLongTimeString()); // 오전 10:31:25
Console.WriteLine(now.ToShortTimeString()); // 오전 10:31

// 프로그램 종료시간
DateTime endTime = DateTime.Now;

Console.WriteLine("프로그램 수행시간 : {0}/ms", (double)(endTime - startTime).Ticks / 1000000.0F);

</pre>

[추가 내용]
/*-- 기간 선택으로 종료일자 변경 --*/
 // 현재날짜 "0000년00월00일" 을 0000년00월1일로 포맷 형식을 변경한다
DateTime nowDate    = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01"));
DataTime chnDate     = nowDate.AddMonths(iMonth+1).AddDays(-1);
/*----*/

2009/11/17 09:48 2009/11/17 09:48
Posted
Filed under C#

[원문]   http://ssis.wik.is/Understanding_Connectivity_Stacks/ADO.NET_vs_OLEDB
OLE DB가 ADO보다 빠르다? ... 딜레마에 빠지는 ...........

An often asked aspect of SSIS is which data source/destination provider to use when connecting to various databases and data sources. In my previous articles, I explained what these connectivity libraries are and how SQL Server Integration Services supports them across the product.


In this article, I will try to provide guidance for when to choose various connectivity options when building SSIS packages. To better structure the pros and cons of using either ADO.NET or OLEDB, I will outline my arguments in terms of product-wide support, performance, 64-bit considerations, and target data source version and type-system supportability.



ADO.NET vs OLEDB : SSIS support across the product


  • First thing to note here is that SSIS is not welcoming ADO.NET and OLE DB connectors equally across the board. Although this is more so in SQL Server 2005, we are making steps to close the gap in Katmai (SQL Server 2008) in between the two. For instance, there is no ADO.NET destination component in our ETL engine Data Flow, and the Lookup component only supports OLE DB. OLE DB is by far the most supported connectivity option across the board. For a full list of supported connectivity options and SSIS components, see my article on the subject: Connectivity_Libraries


ADO.NET vs OLEDB : Performance

  • Performance is very much dependent on the computing environment along with the data and network load levels in your scenario. We highly recommend slicing your end-end scenario into isolated sub scenarios to see where the performance bottleneck is. RowCount component comes particularly handy where you can replace source and destination components with. By replacing the connectors with the RowCount component, which does not incur any I/O and frees memory as an inline component, you are indeed collecting benchmark performance numbers with and without the connector. This will give you the time the connector spends reading/writing the data.


  • That being said, OLE DB, for most cases will have better performance than ADO.NET. This is due to ADO.NET being a managed façade, and providing more abstraction with a little more performance overhead.

ADO.NET vs OLEDB : 64bit considerations

  • Since ADO.NET is a managed interface, the deployment of packages and moving them around 32bit and 64bit boxes will be easier compared to the experience with OLE DB providers. By now, you must have known that SSIS design time is a 32bit application because of the dependency on Visual Studio, which forces it to work with 32bit connectors only. However, during runtime, you have the option to choose a native 64bit or a 32bit connector. Please read my article on 64bit and why things are the way they are here: 64-bit_Story


  • Some OLE DB providers are 32bit only (i.e. MS Office connectivity via JET and ACE OLEDB providers), whereas others support both architectures (i.e. Oracle’s own OLE DB provider for Oracle). To work in a seamless 64bit environment, make sure your provider has both binaries and are available on your deployment environment.


  • That being said, an OLE DB provider being available only in 32bit (i.e. JET), does not necessarily mean that you cannot run it on 64bit platforms. This can be done using the WOW64 emulation mode, which is Windows support for running 32bit applications on 64bit architectures. The only downside to using WOW64 is if you need the 64bit address space which comes with massive memory (i.e. greater than 4GB). Otherwise, it’s not a problem.


ADO.NET vs OLEDB : Target data source & data type supportability


  • Connectors, whether they are ADO.NET or OLE DB providers, don’t support a specific target database/application system equally. For instance, the OLE DB providers for DB2 are all different in the way they support different flavors of DB2. Some support DB2 on Linux, others support DB2 on AS/400, etc…For a good list of connectors and what actually they support, please see the table we are compiling in our connectivity wiki: Data_Sources


  • Another key support question is whether these connectors support a specific version of the target database and how good they are in dealing with a recently introduced data type. For instance, Microsoft’s Oracle OLE DB provider was not recently updated to fully support new data types in Oracle 10g +…However, Microsoft’s ADO.NET provider for Oracle does a better job with Oracle data types. Again, this wiki is a good place to start and contribute to this very organic structure of the connectivity realm.


We also have a white paper on connectivity which covers other aspects of this subjst, it’s a good read: Connectivity_White_Paper 


Deniz Erkan - msft

2009/11/16 13:21 2009/11/16 13:21
Posted
Filed under C#
콤보박스 속성 중
DropDownStyle
에서 DropDownList  옵션을 선택 한다.
2009/11/13 17:22 2009/11/13 17:22
Posted
Filed under C#

\r\n  <-- TextBox에 글쓸 경우 엔터 누름

2009/07/18 12:07 2009/07/18 12:07