我想在面板上绘制以下文本:
这是一个多颜色的文本。
我找到了这篇关于绘制彩色文本的文章。
我用单词替换了字符,但它不起作用。
(我使用FillPath/DrawPath来绘制文本)
我的代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
const string txt = "C# Helper! Draw some text with each letter in a random color.";
// Make the font.
using (Font the_font = new Font("Times New Roman", 40,
FontStyle.Bold | FontStyle.Italic))
{
// Make a StringFormat object to use for text layout.
using (StringFormat string_format = new StringFormat())
{
// Center the text.
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoClip;
// Make …
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序的主仪表板中使用 Picturebox 控件作为按钮。
PictureBox 当然有一个 Image 来标识 Button 函数。
如果我使用普通按钮控件,禁用时,按钮图像会自动变灰。
使用 PictureBox 不会发生这种情况。
如何使用图片框生成相同的效果。
在我的程序中,我使用 OpenFileDialog 组件并设置了一个初始目录。
但是,如果我决定从另一个文件夹打开文件,下次我想打开文件时,OpenFileDialog 会记住我用来打开文件的最后一个文件夹,它将打开该文件夹,而不是 InitialDirectory 中指定的文件夹。我很高兴事情是这样的。即使我关闭并重新打开应用程序,最后使用的文件夹仍然会被记住。
有没有办法找出哪个是文件夹?比方说,当我单击按钮时,我希望最后的路径显示在标签中。
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = @"C:\My Initial Folder";
Run Code Online (Sandbox Code Playgroud) 作为参考,此代码来自对这个问题的回答:
突出显示颜色与 RichTextBox 文本中所有其他选择不同的单词或短语?
using System.Collections.Generic;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
private class TextSearcher
{
private BindingSource m_bsMatches = null;
private RichTextBox m_Rtb = null;
public TextSearcher(RichTextBox rtb) : this(rtb, Color.Yellow, Color.Red) { }
public TextSearcher(RichTextBox rtb, Color selectionColor, Color currentColor)
{
this.m_Rtb = rtb;
SelectionColor = selectionColor;
CurrentColor = currentColor;
}
public string CurrentKeywords { get; private set; } = string.Empty;
public bool CaseSensitive { get; set; } = true;
public int CurrentIndex => m_bsMatches.Position;
public Match CurrentMatch …
Run Code Online (Sandbox Code Playgroud) 我试图将文本文件的加密内容复制到内存流中,然后解密这些内容并将其复制到新的内存流中。当我到达发生复制的代码时,我在调试时收到无效数据错误。
这是我得到的代码块:
Function DecryptFile(ByVal sInputFilename As String, ByVal sKey As String) As Byte()
Dim DES As New DESCryptoServiceProvider()
DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey)
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor()
Dim encryptedByteArray() As Byte
encryptedByteArray = File.ReadAllBytes(sInputFilename)
Dim encryptedMS As MemoryStream = New MemoryStream(encryptedByteArray)
Dim cryptostreamDecr As New CryptoStream(encryptedMS, desdecrypt, CryptoStreamMode.Read)
Dim decryptedMS As MemoryStream = New MemoryStream()
cryptostreamDecr.CopyTo(decryptedMS) 'Error occurs here
cryptostreamDecr.Close()
Return decryptedMS.ToArray()
End Function
Run Code Online (Sandbox Code Playgroud)
我正在关注散布在网络上的示例,从我读过的内容来看,这段代码应该可以工作......
谁能向我解释我做错了什么?
当项目被选中时,我尝试从组合框中的图像列表中绘制图像。
我能够绘制图像,但是当onSelctedIndexChanged
活动结束时,我丢失了图像。
我的组合框已经有了 DrawMode.OwnerDrawFixed
我有一个ListImage
名为 ImageList的控件,其中包含 10 张图片。
对于我的简短示例,我只需要在我的组合框中绘制 ImageList 位置 1 处的图像,这就是为什么我得到 this.ImageList.Draw(g, 0, 0, 1 );
protected override void OnSelectedIndexChanged(EventArgs e)
{
base.OnSelectedIndexChanged(e);
if (this.SelectedIndex > -1)
{
var g = this.CreateGraphics();
this.ImageList.Draw(g, 0, 0, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
可能我没有依附于正确的事件。有什么建议吗?
在 Draw 之后的 IndexChanged 中有一个断点,请参见下图。它的工作,但我失去了我的事件后的形象。
我给了我的 API 响应,请帮助我如何使用 Deserialize 在类中设置数据
{
"result": [
{
"encabezado": {
"resultado": "true",
"imensaje": "",
"mensaje": "",
"tiempo": "28"
},
"respuesta": {
"datos": {
"crear": "true"
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
你能帮忙教下如何在课堂上设置吗
我像这样使用它:
var json = "{'result': " +
"[{'encabezado': " +
"{'resultado': 'true','imensaje': '','mensaje': '','tiempo': '28'}," +
"'respuesta': " +
"{'datos': {'crear': 'true'}}}]}";
result info = JsonConvert.DeserializeObject(json);
Run Code Online (Sandbox Code Playgroud)
public class encabezado
{
public string resultado { get; set; }
public string imensaje { get; set; }
public string mensaje { …
Run Code Online (Sandbox Code Playgroud) handleClick(event) {
let value = event.target.value;
this.setState({ question: (this.state.question += value) });
Run Code Online (Sandbox Code Playgroud)
我收到警告:
不要直接改变状态。使用setState()react / no-direct-mutation-state
如果我尝试用此代码加载页面。
我该如何解决,以免出现警告?
它说要使用this.setState
,但这就是我正在做的。
c# ×6
winforms ×6
graphics ×3
.net ×2
combobox ×1
des ×1
drawimage ×1
drawstring ×1
encryption ×1
graphicspath ×1
javascript ×1
json ×1
jsx ×1
picturebox ×1
reactjs ×1
tripledes ×1
vb.net ×1
winapi ×1