小编Fai*_*ist的帖子

在TextBox中制作特定的文本Boldefaced

嗨我目前有一个texbox,当用户按下不同的按钮时会向用户输出信息.我想知道是否有办法让我的一些文字加粗,其余的不是.

我尝试过以下方法:

textBox1.FontWeight = FontWeights.UltraBold;
textBox1.Text. = ("Your Name: " );
TextBox1.FontWeight = FontWeights.Regular;
textBox1.Text += (nameVar);
Run Code Online (Sandbox Code Playgroud)

唯一的问题是,使用这种方式会使一切变得大胆或什么都没有.有没有办法做到这一点?我在C#中使用WPF项目

任何意见或建议表示赞赏.谢谢!

编辑:所以现在我想尝试你所有建议的RichText框,但我似乎无法得到任何东西出现在其中:

// Create a simple FlowDocument to serve as the content input for the construtor.
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Simple FlowDocument")));
// After this constructor is called, the new RichTextBox rtb will contain flowDoc.
RichTextBox rtb = new RichTextBox(flowDoc);
Run Code Online (Sandbox Code Playgroud)

rtb是我在我的wpf中创建的我的richtextbox的名称

谢谢

c# wpf textbox bold

16
推荐指数
3
解决办法
6万
查看次数

如何通过扩展以下类型特征来删除decltype(&MyClass :: funct)部分?

我想拥有类型特征,这将有助于我从成员函数指针中获取类的类型。我调查了这个答案 ,发现我已经达到目标了。

看起来像这样:

#include <iostream>

// example class
struct MyClass {
    void funct() { std::cout << "funct has been called....\n"; }
};

// traits
template<typename Class> struct get_class{};
template<typename ReType, typename Class, typename... Args>
struct get_class<ReType(Class::*)(Args...)>
{
    using type = Class;
};
template<typename Type> using get_class_t = typename get_class<Type>::type;

int main()
{
    get_class_t<decltype(&MyClass::funct)> myObj;
    //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---> this is a lot of typing
    myObj.funct();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是,如代码中所示,我每次都需要编写,get_class_t<decltype(&MyClass::funct)> 或者

  auto ptr =  &MyClass::funct;
  get_class_t<decltype(ptr)> myObj;
  //         ^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

这很多decltype() …

c++ templates member-function-pointers type-traits c++11

15
推荐指数
2
解决办法
378
查看次数

我可以用这种方式声明ArrayList吗?

Iterable<Board> theNeighbors = new ArrayList<Board>();
Run Code Online (Sandbox Code Playgroud)

这是我对ArrayListtheNeighbors的初始化,它使用了interafce Iterable进行声明.但是,当我使用方法add()来构建我刚刚构建的变量时,编译器会发出警报

Board.java:78:错误:找不到符号theNeighbors.add(nb); ^
符号:方法添加(Board)
位置:变量类型Iterable的邻居

是什么让它发生?在我使用的另一种情况

List<Board> theNeighbors = new ArrayList<Board>();
Run Code Online (Sandbox Code Playgroud)

add()方法效果很好.您为声明选择的界面是否应始终具有您稍后要调用的方法?

java arraylist

13
推荐指数
1
解决办法
828
查看次数

将IronPython代码编译为EXE或DLL

我可以在.NET运行时中将IronPython代码编译为EXE或DLL吗?

.net c# ironpython c#-4.0

9
推荐指数
1
解决办法
7529
查看次数

如何在OPENCV中为模式识别定义我们自己的内核?

我想在OpenCV上编写自己的内核用于Image分类.

但对于SVM(Opencv的内置函数),内核已经定义.

我的问题是,OpenCV中有什么东西可以让我定义我的内核吗?

实际上,我想为图像分类实现多核学习.

opencv machine-learning image-processing pattern-matching

9
推荐指数
1
解决办法
172
查看次数

Derived Class对象如何添加到Base Class对象List

鉴于以下代码,我从Shape继承了一个Circle:

class Shape
{
    void Draw();
}

class Circle : Shape
{
}

void Main(string[] args)
{
    Shape s = new Shape();
    Shape s2 = new Shape();
    Circle c = new Circle();

    List<Shape> ShapeList = new List<Shape>();

    ShapeList.Add(s);
    ShapeList.Add(s2);
    ShapeList.Add(c);
}
Run Code Online (Sandbox Code Playgroud)

怎么可以c加入ShapeList

c# oop polymorphism inheritance upcasting

7
推荐指数
1
解决办法
3780
查看次数

阿拉伯文字框

我开发了一个网站:有些字段用英文输入,而其他字段用阿拉伯语输入.

现在我想简化用户的输入操作,并希望阿拉伯文本框作为DLL.

我有一个,但它只适用于IE - 不使用Firefox或谷歌浏览器..

非常感谢..

如何强制用户用阿拉伯语写?我的意思是每次尝试更改语言时都没有(ALT + SHIFT)键直接移动光标......如果有任何方式,属性,DLL或者什么都做...

.net c# asp.net dll visual-studio

6
推荐指数
1
解决办法
4903
查看次数

jQuery fullcalendar 到波斯语

我想将 jquery fullcalendar 更改为波斯日历。

我正在使用此代码:

   isRTL: true,
    monthNames: ['???????', '????????', '?????', '???', '?????', '??????',
                '???', '????', '???', '??', '????', '?????'],
    monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
    dayNames: ['??????', '??????', '???????', '????????', '???????', '????', '????'],
    dayNamesShort: ['??????', '??????', '???????', '????????', '???????', '????', '????'],
    dayNamesMin: ['??????', '??????', '???????', '????????', '???????', '????', '????'],
    weekHeader: '????',
    dateFormat: 'yy/mm/dd',
    firstDay: 6,
Run Code Online (Sandbox Code Playgroud)

我的用户界面已更改,但日历可能不是波斯语

javascript jquery jquery-plugins

6
推荐指数
1
解决办法
2200
查看次数

当我们将指针打印到字符类型时,为什么C++会显示字符?

请考虑以下代码:

char char_a = 'A';
int int_b = 34;

char* p_a = &char_a;
int* p_b = &int_b;

cout<<"Value of int_b is (*p_b) :"<< *p_b<<endl;
cout<<"Value of &int_b is (p_b) :"<< p_b<<endl;

cout<<"Value of char_a is (*p_a) :"<< *p_a<<endl;
cout<<"Value of &char_a is (p_a) :"<< p_a<<endl;
Run Code Online (Sandbox Code Playgroud)

当我运行它时,输出是:

在此输入图像描述

那么为什么不在char指针的情况下显示地址,就像它对整数的指针一样?

c++ pointers

6
推荐指数
1
解决办法
291
查看次数

在C++中exit和std :: exit有什么区别?

exitstd::exitC++有什么区别?我研究了它,但我找不到任何东西.

这两个代码有什么区别:

1:

if(SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
    std::cout << "Error: Can't initialize the SDL \n";
    exit(EXIT_FAILURE);
}
Run Code Online (Sandbox Code Playgroud)

2:

if(SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
    std::cout << "Error: Can't initialize the SDL \n";
    std::exit(EXIT_FAILURE);
}
Run Code Online (Sandbox Code Playgroud)

c++ exit

6
推荐指数
2
解决办法
2555
查看次数