当前位置:首页 > 技术心得 > 正文内容

C# 一些基本的控件代码

xjtudll9年前 (2018-01-17)技术心得8080

c# 怎么用代码设置picturebox的大小,位置

picturebox.Location = new Point(x,y) 位置picturebox.Size = new Size(0,0);大小,Size里面的参数自己设置,前面是宽度,后面是高度

如何用C# 打开和保存BMP文件

操作如下:

Bitmap _Bitmap = (Bitmap)Image.FromFile(@"c:\1.BMP");

       BitmapData _BitmapData = _Bitmap.LockBits(new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height), ImageLockMode.ReadWrite, _Bitmap.PixelFormat);

      byte[] _Value = new byte[_BitmapData.Stride * _BitmapData.Height];

     Marshal.Copy(_BitmapData.Scan0, _Value, 0, _Value.Length);

   写回去还是用 Marshal.Copy.

C#--整型与字节数组byte[]之间的转换

int  i = 123;

byte [] intBuff = BitConverter.GetBytes(i);    // 将 int 转换成字节数组

lob.Write(intBuff, 0, 4);

i = BitConverter.ToInt32(intBuff, 0);          // 从字节数组转换成 int

double x = 123.456;

byte [] doubleBuff = BitConverter.GetBytes(x);  // 将 double 转换成字节数组

lob.Write(doubleBuff, 0, 8);

x = BitConverter.ToDouble(doubleBuff, 0);      // 从字节数组转换成 double

C#获取鼠标相对当前窗口坐标的实现方法

使用PointToClient计算鼠标相对于某个控件的坐标,如下

Point screenPoint = Control.MousePosition;//鼠标相对于屏幕左上角的坐标

Point formPoint = this.PointToClient(Control.MousePosition);//鼠标相对于窗体左上角的坐标

Point contextMenuPoint = contextMenuStrip1.PointToClient(Control.MousePosition); //鼠标相对于contextMenuStrip1左上角的坐标

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://xjtudll.cn/Exp/488/

标签: C#
分享给朋友:

“C# 一些基本的控件代码” 的相关文章

51串口通信

51串口通信

大学的时候,练习串口通信整的东东图太大,显示不正常。请直接看原图。upload/2010/1/201001291823133003.jpg演示如图: 左边的单片机:发送  查询方式右边的单片机:接收    中断方式K1:LED1亮;K2:LED2亮;...

Quartus II Warning: Found 6 node(s) in clock paths which may be acting as ripple and/or gated clocks

Quartus II编译某代码之后,老是提示如下warning: Warning: Found 6 node(s) in clock paths which may be acting as ripple and/or gated clocks -- node(s) analyzed as buf...

金蝶K3老单插件开发-如何刷新单据、锁定单据

在金蝶K3工业老单插件开发中,用SQL在后台更新了单据数据,如何刷新单据,将新的值显示在单据上?用 m_BillTransfer.DoRefreshControl方法是不行的,需要使用如下方法: m_BillTransfer.BillFunc.ReFillBill 再介绍几个K3工业老单BillFu...

Keil  error C272: '__asm' requires src-control to be active 解决办法

Keil error C272: '__asm' requires src-control to be active 解决办法

问题: 在C代码里加入了__asm语句,例如“__asm POP 7”,编译出现Error error C272: '__asm' requires src-control to be active 解决办法: 右键选中该文件----option for file"...

工作台待处理业务、待处理流程、待审批、我的跟进、预警、消息对应的数据表

https://vip.kingdee.com/questions/152510144306059546/answers/152510187037628697 工作台待处理业务、待处理流程、待审批、我的跟进、预警、消息对应的数据表如下: 待处理业务:t_SuspendWorkPushMain、t_S...

水晶报表字符串字体大小根据字数调整

在实际应用中,可能需要根据字数多少来调整字体的大小。简单介绍一个方法。          选择要设置的字段,右键->设置对象格式->字体->大小,单击右边的x+2进入公式工作室,输入如下代码: if L...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。