![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
余道长
乾坤未定你我皆是黑马。
展开
-
C# 自定义下拉框样式详细代码,修改下拉框大小、颜色、图案。
【代码】C# 自定义下拉框样式详细代码,修改下拉框大小、颜色、图案。原创 2023-03-10 14:02:16 · 840 阅读 · 0 评论 -
HTTP POST请求发送JSON参数 415错误
发生415错误需要检查ContentType 是否正常。原创 2023-02-10 15:40:15 · 294 阅读 · 0 评论 -
C# 反射GetProperty()为null 解决方案
C# 反射GetProperty()为null 解决方案原创 2023-01-12 10:47:45 · 1019 阅读 · 0 评论 -
分享一款好用的接口测试工具Apifox
分享一款好用的接口测试工具Apifox原创 2022-09-19 10:14:11 · 129 阅读 · 0 评论 -
C# 芯片方案文档字节【1:0】含义
A字节【1:0】原创 2022-09-02 16:32:52 · 295 阅读 · 0 评论 -
C# 带参数启动程序
C# 带参数启动程序原创 2022-07-16 13:36:15 · 676 阅读 · 0 评论 -
C# byte[] 大小端转换
大小端转换原创 2022-07-12 11:06:57 · 806 阅读 · 0 评论 -
C# 指定网口进行TCPIP连接
TCPIP指定网口连接服务端原创 2022-06-21 14:18:42 · 989 阅读 · 0 评论 -
C# 16进制 Tostring()
16进制转string原创 2022-07-12 11:05:49 · 1353 阅读 · 0 评论 -
C# switch 多个值指向同一代码块
C# switch 多个值指向同一代码块原创 2022-06-09 14:22:35 · 682 阅读 · 0 评论 -
WPF DataGrid 样式设置 隔行变色 居中等
控件 <DataGrid Width="1313" Height="749" IsReadOnly="True" BorderBrush="#BCBCBC" Margin="0 6 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" CanUserDeleteRows="False" CanUserReorderColumns="False.原创 2022-05-23 15:07:37 · 935 阅读 · 0 评论 -
WPF 自定义控件,自定义属性
自定义控件定义自定义属性 public class CustomDetails : Control { static CustomDetails() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomDetails), new FrameworkPropertyMetadata(typeof(CustomDetails))); } public.原创 2022-05-23 15:05:15 · 2117 阅读 · 0 评论 -
WPF 控件模板触发器
<ControlTemplate x:Key="btntemp"> <Border BorderBrush="#2A62B8" Background="{TemplateBinding Button.Background}" BorderThickness="1" CornerRadius="7,7,7,7"> <ContentPresenter Content="{TemplateBinding ContentCo...原创 2022-05-16 09:30:09 · 302 阅读 · 0 评论 -
C# 实用快捷键
Propfull Tab Tab private int myVar; public int MyProperty { get { return myVar; } set { myVar = value; } }Prop Tab Tab public int MyProperty { get; set; }..原创 2022-05-06 17:11:09 · 396 阅读 · 0 评论 -
VS 自定义代码段(以下为WPF举例子)
原创 2022-05-06 16:56:54 · 169 阅读 · 0 评论 -
C# 高低位字节互换
byte[]buffer=Encoding.ASCII.GetBytes(data);byte[]temp=newbyte[buffer.Length+4];temp[0]=(byte)(length&0xFF);temp[1]=(byte)((length&0xFF00)>>8);...原创 2022-04-29 15:26:44 · 5104 阅读 · 0 评论 -
WPF 双向绑定下拉框ComboBox
<ComboBox Width="210" Height="28" Margin="102,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" pu:ComboBoxHelper.CornerRadius="4" DisplayMemberPath="Name" ...原创 2022-04-24 17:16:47 · 1224 阅读 · 0 评论 -
C# 获取类的属性名
普通的Type t = 类.GetType();//获得该类的Type foreach (PropertyInfo pi in t.GetProperties()) { var name = pi.Name;//获得属性的名字,后面就可以根据名字判断来进行些自己想要的操作 var value = pi.GetValue(PLCcontrl, null);//用pi.GetValue获得值...原创 2022-04-15 09:08:43 · 2923 阅读 · 0 评论 -
C#多线程程序CPU占用巨高,解决方案
代码问题!代码问题!代码问题!找whlie循环中是否Sleep线程,Sleep(1);即可解决问题。原创 2022-04-06 17:55:05 · 2026 阅读 · 0 评论 -
WPF 布局记录
WrapPanel水平布局StackPanel.垂直布局StackPanel的Orientation='Horizontal'实现水平排列原创 2022-03-14 13:32:26 · 290 阅读 · 0 评论 -
Modbus 调试详情
Modbus Slave工具使用说明原创 2022-03-10 13:19:26 · 74 阅读 · 0 评论 -
局域网访问共享文件
\\192.168.188.1原创 2022-02-25 16:46:47 · 159 阅读 · 0 评论 -
C# 保存配置文件,不存在则创建
public static void SetAppConfig<T>(string appKey, T value, string description = "") { string appValue = ""; Type t = typeof(T); if (t.Name == "Boolean") { appValue = bool.Parse..原创 2021-12-13 13:36:59 · 533 阅读 · 0 评论 -
Winfrom 右下角消息通知动画显示
添加以下两个类using System;using System.Collections.Generic;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;namespace FileX{ internal static class NativeMethods { /// <summary>原创 2021-11-17 14:15:52 · 96 阅读 · 0 评论 -
C# DatagridView 绑定List集合,绑定数据源后显示空白
窗体列名设置属性DataPropertyname对应List集合得字段类得字段一定要加get set 不要图方便! public class SAea { public string Size { get; set; }//要加get set 不然显示空白哦 public string Type { get; set; } public string Num { get; set; } public.原创 2021-11-08 16:39:37 · 935 阅读 · 0 评论 -
C# 正则表达式删除数字、字母,只保留下划线和汉字
string str=Regex.Replace(key, @"\d|\W|[A-Za-z]", "");原创 2021-11-04 13:56:54 · 773 阅读 · 0 评论 -
网络通讯数据安全性建议,最后两个字节为前面字节的CRC校验
网络通讯数据安全性建议,最后两个字节为前面字节的CRC校验原创 2021-11-03 16:01:50 · 212 阅读 · 0 评论 -
C# crc16位校验和多个字节组成int
int num = Int32.Parse(byteDateLine[3].ToString("X2") + byteDateLine[4].ToString("X2"), System.Globalization.NumberStyles.HexNumber);//多个字节转int//CRC校验 public static bool CRCCalc(byte[] data) { try { if (C...原创 2021-11-02 15:09:46 · 226 阅读 · 0 评论 -
C# 替换字符串中两个字符之间的内容 正则表达式替换
Regex r = new Regex("(?<=(A))[.\\s\\S]*?(?=(B))");//A为起始字符 B为结束字符 string Str="A123456123B";Str= r.Replace(Str, "*", 1);//*为替换字符串 1为替换最大次数 Console.WriteLine(Str);//输出A*B原创 2021-11-02 10:51:42 · 1624 阅读 · 0 评论 -
WPF 控件自定义模板(举例如一个单选菜单)
样式代码!<UserControl.Resources> //定义一个样式 <Style x:Key="RadButton" TargetType="RadioButton"> <Setter Property="Margin" Value="12 20 0 0"/> <Setter Property="Background" Value="Red" /> ...原创 2021-09-26 17:49:17 · 268 阅读 · 0 评论 -
WPF LIvecharts 表格设置X Y轴间距
<lvc:CartesianChart Series="{Binding Collection}" Width="409" Height="322" Canvas.Left="17" Canvas.Top="62" LegendLocation="None"> <lvc:CartesianChart.AxisX> <lvc:Axis MinValue="0">//从0开始 ...原创 2021-09-24 11:53:41 · 2249 阅读 · 0 评论 -
WPF MVVM Livecharts 柱状图
水平柱状图使用绑定 RowSeries Labels = new string[] { "09-01", "09-02", "09-03", "09-04", "09-05", "09-06", "09-07", "09-08", "09-09", "09-10" }; Datatimes = new string[] { "09-01", "09-02", "09-03", "09-04" }; List<double> columnVal...原创 2021-09-24 11:30:45 · 2038 阅读 · 1 评论 -
C# 资源文件相关
原创 2021-09-23 17:35:09 · 44 阅读 · 0 评论 -
C# Invoke与BeginInvoke
实时响应用Invoke this.Invoke(new Action(() => { }));无需实时响应用BeginInvoke this.BeginInvoke(new Action(() => { }));...原创 2021-09-23 09:47:10 · 369 阅读 · 0 评论 -
C# 频繁操作string导致卡顿耗时长!StringBuilder解决问题!
未修改代码: Stopwatch stop = new Stopwatch();stop.Start(); string str = ""; foreach (var item in dicImage) { str += $"{item.Name}?"; foreach (var ty in item.Types) {原创 2021-09-17 13:43:40 · 714 阅读 · 0 评论 -
WPF 绘制相关
https://www.pianshen.com/article/7547495186/原创 2021-09-08 15:57:58 · 48 阅读 · 0 评论 -
WPF 用户控件上无法调用Command得标签可使用事件调用command得方法。如下。
用户控件视图代码: <TextBox Name="TextB" Width="364" Height="38" FontSize="24" Background="Transparent" BorderThickness="0" VerticalContentAlignment="Center" Foreground="#6076AD" HorizontalAlignment="Left" Text="请输入设备编号"/>用户控件后台代码:private void Imag...原创 2021-08-25 16:43:15 · 456 阅读 · 0 评论 -
WPF 踩坑 DataGrid DataGridTextColumn根据文本内容改变颜色绑定转换器
Foreground 属性不会触发转换器!!!!!!!!!!!Foreground 属性不会触发转换器!!!!!!!!!!!Foreground 属性不会触发转换器!!!!!!!!!!!原创 2021-08-24 11:32:24 · 497 阅读 · 0 评论 -
WPF LiveCharts 圆环图表
<lvc:PieChart Grid.Row="1" Height="302" Width="264" Canvas.Left="162" Canvas.Top="65" Series="{Binding PieSeriesCollection}" SeriesColors="{Binding CloCollection}" InnerRadius="80"> </lvc:PieChart>InnerRadius:内...原创 2021-08-23 11:59:51 · 954 阅读 · 0 评论 -
winfrom Chart 图标控件设置 Title.BackImage异常解决方案
Bitmap bmp = global::CustomControl.TitleControlResource.微信图片_20210514110135; NamedImage ni = new NamedImage("test", bmp); chart1.Images.Add(ni); chart1.Titles[0].BackImage = "test";原创 2021-06-03 12:02:51 · 114 阅读 · 0 评论