易截截图软件、单文件、免安装、纯绿色、仅160KB

根据宽度来决定显示的字符串长度(C#)

根据宽度来决定显示的字符串长度 (C#,VS2005)
如果 lable长度固定但字符串长度可变,如果超过了lable显示的长度时,希望用 ...代替剩下的字符,这时需要一个函数
Graphics.MeasureString
具体代码如下
  public string Abbreviation(string str)
        {
            if (str == null)
            {
                return null;
            }
            int strWidth = FontWidth(txtName.Font, txtName, str);
            //获取label最长可以显示多少字符
            int len = label.Width * str.Length / strWidth;
            if (len > 3 && len < str.Length)
            {
                return str.Substring(0, len - 3) + "...";
            }
            else
            {
                return str;
            }
        }
        /// <summary>
        /// 获取字符串在 font时的长度
        /// </summary>
        private int FontWidth(Font font, Control control, s


相关文档:

C#和JavaScript的简单互交

1.asp.net呼叫js
   
                     Response.Write("<script language=javascript>");
              &n ......

C#里对xml文件进行修改,新增,删除,插入操作

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price> ......

asp.net c# 数据库备份

protected void btnsearch_ServerClick(object sender, EventArgs e)
    {
        string lujing=this.Text2.Value.ToString().Trim();
        string shujuku = this.jine.Value;
      &nbs ......

c# 连接MySql数据库的两种方法

1、用MySQLDriverCS连接MySQL数据库
先下载和安装MySQLDriverCS,地
址:
http://sourceforge.net/projects/mysqldrivercs/
在安装文件夹下面找到
MySQLDriver.dll
,然后将
MySQLDriver.dll
添加引用到项目中
注:我下载的是版本是

MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
 
using

S ......

c# 将枚举作为键值的形式存储

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace 将枚举作为键值的形式存储
{
    enum Myenum
    {
       First=3,
       Second ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号