登录
首页 » C#源码 » C# 以WrapWithOverflow方式、Wrap方式、NoWrap方式显示文字

C# 以WrapWithOverflow方式、Wrap方式、NoWrap方式显示文字

于 2022-01-25 发布 文件大小:28.58 kB
0 250
下载积分: 2 下载次数: 1

代码说明:

C#以三种方式显示文字,分别以WrapWithOverflow方式、Wrap方式、NoWrap方式将文字显示在窗口中,这三种方式实现的代码请看以下代码:   private void button1_Click(object sender, RoutedEventArgs e)   {//WrapWithOverflow方式    this.MyTextBlock.TextWrapping = System.Windows.TextWrapping.WrapWithOverflow;   }   private void button3_Click(object sender, RoutedEventArgs e)   {//Wrap方式    this.MyTextBlock.TextWrapping = System.Windows.TextWrapping.Wrap;   }   private void button2_Click(object sender, RoutedEventArgs e)   {//NoWrap方式    this.MyTextBlock.TextWrapping = System.Windows.TextWrapping.NoWrap;   }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C# 确定字符串末尾是否匹配指定子串
    C# 确定字符串末尾是否匹配指定子串,本字符串查询实例具体到只匹配字符串开头和结尾是否有指定的字符串,下面是具体的查询代码编写方法:   private void button1_Click(object sender, EventArgs e)   {//确定字符串开头是否匹配指定子串    string MyFullInfo = "中华人民共和国";    string MyPartInfo="中华";    if(MyFullInfo.StartsWith(MyPartInfo))    MessageBox.Show(MyFullInfo + " 的开头是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);    else    MessageBox.Show(MyFullInfo + " 的开头不是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);   }   private void button2_Click(object sender, EventArgs e)   {//确定字符串末尾是否匹配指定子串    string MyFullInfo = "中华人民共和国";    string MyPartInfo = "共和国";    if (MyFullInfo.EndsWith(MyPartInfo))    MessageBox.Show(MyFullInfo + " 的末尾是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);    else    MessageBox.Show(MyFullInfo + " 的末尾不是 " + MyPartInfo, "信息提示", MessageBoxButtons.OK);   }
    2022-02-09 23:32:04下载
    积分:1
  • C#使用SqlDataAdapter对象的Fill方法填充DataSet
    C#使用SqlDataAdapter对象的Fill方法填充DataSet,具体是调用DataSet的Copy方法复制DataSet中的内容,完成填充的功能:   private void Form1_Load(object sender, EventArgs e)   {    //实例化SqlConnection变量conn,连接数据库    conn = new SqlConnection("server=.;database=db_14;uid=sa;pwd=");    //创建一个SqlCommand对象    SqlCommand cmd = new SqlCommand("select * from tb_test", conn);    SqlDataAdapter sda = new SqlDataAdapter();//创建一个SqlDataAdapter对象    //设置SqlDataAdapter对象的SelectCommand属性,设置执行的SQL语句    sda.SelectCommand = cmd;    ds = new DataSet(); //实例化DataSet    sda.Fill(ds, "test");//使用SqlDataAdapter对象的Fill方法填充DataSet    dataGridView1.DataSource = ds.Tables[0];//设置dataGridView1的数据源   }   private void button1_Click(object sender, EventArgs e)   {    DataSet ds1 = ds.Copy();//调用DataSet的Copy方法复制ds中的内容    dataGridView2.DataSource = ds1.Tables[0];//将ds1作为dataGridView2的数据源   }
    2022-11-04 09:50:03下载
    积分:1
  • C# 建立SQL Server数据库连接的基本方法
    C# 建立SQL Server数据库连接的基本方法,核心代码为:   try   {    string ConStr =//创建数据库连接字符串   @"server=WIN-GI7E47AND9RLS;user id=sa;pwd=;database=db_TomeTwo";    SqlConnection con = new SqlConnection(ConStr);//创建数据库连接对象    string SqlStr = "select * from 帐单";//创建SQL查询字符串    SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);//创建数据适配器对象    DataSet ds = new DataSet();//创建数据表    ada.Fill(ds);//填充数据集    this.dgv_Message.DataSource =//设置数据源    ds.Tables[0].DefaultView;   }   catch(Exception ex)//捕获异常   {    MessageBox.Show(ex.Message,"提示!");//弹出消息对话框   }
    2022-07-28 04:06:36下载
    积分:1
  • C# WPF 使用几何路径实现动画旋转按钮
    Visual C# 使用几何路径来实现动画效果的旋转按钮,这是一个wpf类型的C#实例,运行Bin目录下的exe文件,你会发现整个按钮会在窗体的范围内沿预先设定好的几何路径来运动,就像过山车一样,按钮的方向和按钮文字的方向同时发生改变,正在运动中的按钮效果,请参见截图所示。
    2022-05-22 01:33:58下载
    积分:1
  • C# 使用Graphics对象在程序运行时创建位图
    C# 在程序运行时创建位图,本源码实例主要是学习使用使用Graphics对象创建简单图像的例子,本程序将生成一条曲线图像,参照如下代码:   {//在程序运行时创建位图   int MyWidth=this.pictureBox1.Width;   int MyHeight=this.pictureBox1.Height;   Bitmap MyBitmap = new Bitmap(MyWidth,MyHeight);   Graphics MyGraphics = Graphics.FromImage(MyBitmap);   Pen MyPen = new Pen(Color.Black, 3);   Point[] MyPoints = { new Point(50, 100), new Point(100, 10), new Point(150, 290), new Point(200, 100), new Point(250, 10), new Point(300, 290), new Point(350, 100) };   MyGraphics.Clear(Color.White);   MyGraphics.DrawBeziers(MyPen, MyPoints);   pictureBox1.Image = MyBitmap;
    2022-03-25 22:38:21下载
    积分:1
  • 小球弹跳运动 小球位移动画效果实例_C#
    基于C#实现的小球弹跳运动 小球位移动画效果实例,WPF类型的C#源代码例子,欢迎初学者学习参考。
    2022-10-29 08:25:03下载
    积分:1
  • C# 根据路径使用DirectoryInfo创建文件夹
    C# 根据路径创建文件夹,具体来说是使用DirectoryInfo对象的Create方法创建文件夹【目录】。如果用户未指定路径,则在程序当前目录下创建文件夹,若指定路径,则在指定的路径层级下创建目录。   在创建开始前,对用户输入的目录名或路径格式进行验证,然后判断该路径下是否存在该目录,最后创建文件夹。下面是相关的代码:   if (textBox1.Text == string.Empty)//判断输入的文件夹名称是否为空   {    MessageBox.Show("文件夹名称不能为空!");   }   else   {    DirectoryInfo dinfo = new DirectoryInfo(textBox1.Text);//实例化DirectoryInfo类对象    if (dinfo.Exists)//使用DirectoryInfo对象的Exists属性判断要创建的文件夹是否存在    {    MessageBox.Show("该文件夹已经存在");    }    else    {    dinfo.Create();//使用DirectoryInfo对象的Create方法创建文件夹    }   }
    2023-02-21 06:20:03下载
    积分:1
  • C# wpf 创建简单形状动画的例子
    C# wpf 创建简单形状动画的例子,启动动画、停止动画、暂停动画、继续动画、加速动画。创建动画   Rectangle MyRectangle = new Rectangle();   MyRectangle.Width = 50;   MyRectangle.Height = 20;   MyRectangle.Margin = new Thickness(10, 50, 0, 0);   MyRectangle.Fill = new LinearGradientBrush(    Color.FromArgb(255, 0, 255, 255), Color.FromArgb(255, 0, 0, 255), 0);   MyRectangle.HorizontalAlignment = HorizontalAlignment.Left;   this.canvas1.Children.Add(MyRectangle);   this.RegisterName("MyRectangle", MyRectangle);   DoubleAnimation MyAnimation =    new DoubleAnimation(100, 380, new Duration(TimeSpan.FromSeconds(5)));   Storyboard.SetTargetName(MyAnimation, "MyRectangle");   Storyboard.SetTargetProperty(MyAnimation,    new PropertyPath(Rectangle.WidthProperty));   MyStoryboard = new Storyboard();   MyStoryboard.Children.Add(MyAnimation);   动画效果请参见下图所示,源代码请单击下载按钮下载。
    2022-08-25 13:04:57下载
    积分:1
  • C# WPF 制作3D动画旋转的地球 超赞 附源码
    C# WPF 制作3D动画旋转的地球 超赞 附源码,在源代码中使用了3DTools.dll,不过这仍然是一个非常棒的三维动画实例,使用WPF技术,将一幅静态的BMP地球图像,制作成动态的圆形的地球旋转动画,超逼真的地球动画,请参见测试截图。本源码可为广大C#爱好者学习WPF技术提供一个得力的参考。
    2022-03-22 09:21:02下载
    积分:1
  • C# 读取GDI+图像元数据
    C# 读取GDI+图像元数据,比如可读取图片的长度和宽度/ID/类型等信息.
    2023-04-30 06:00:03下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载