小编Ehs*_*san的帖子

如何选择Windows窗体文本框中的所有文本?

我想选择文本框中的所有文本.

我试过这个使用下面的代码:

textBoxResults.SelectionStart = 0;
textBoxResults.SelectionLength = textBoxResults.Text.Length;
Run Code Online (Sandbox Code Playgroud)

来源:我从这里得到了这个代码http://msdn.microsoft.com/en-us/library/vstudio/hk09zy8f(v=vs.100).aspx 但由于某种原因它似乎不起作用.

c# textbox selectall winforms

18
推荐指数
1
解决办法
4万
查看次数

如何定义类型T必须具有字段"ID"

这个样本:

public static void createDictionary<T>(IEnumerable<T> myRecords)
            where T: T.ID // Wont Compile
        {
            IDictionary<int, T> dicionario = myRecords.ToDictionary(r => r.ID);


            foreach (var item in dicionario)
            {
                Console.WriteLine("Key = {0}",item.Key);

                Type thisType = item.Value.GetType();

                StringBuilder sb = new StringBuilder();

                foreach (var itemField in thisType.GetProperties())
                {
                    sb.AppendLine(string.Format("{0} = {1}", itemField.Name, itemField.GetValue(item.Value, null)));
                }

                Console.WriteLine(sb);
            }

        }
Run Code Online (Sandbox Code Playgroud)

如何强制传递的类型作为参数有一个名为"ID"的字段?

.net c# generics

3
推荐指数
2
解决办法
2023
查看次数

从列表访问字典时的异常

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<object> list = new List<object>();
            List<Dictionary<string, object>> dict = new List<Dictionary<string, object>>();

            Dictionary<string, object> master = new Dictionary<string, object>();
            master.Add("list", list);
            master.Add("dict", dict);

            List<object> mydict = (List<object>)master["dict"]; // this is where i get exception
            Console.Write("Count: ", mydict.Count);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它在粗线上抛出异常.为什么这种行为以及如何访问此元素?谢谢Sumanth

c# list

2
推荐指数
1
解决办法
109
查看次数

我如何在c#windows窗体中隐藏关闭按钮

我有一个模态对话框,需要隐藏Close(X)按钮,但我不能使用ControlBox = false,因为我需要保持Minimize和Maximize按钮.

我需要隐藏关闭按钮,有没有办法做到这一点?

c# winforms

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

如何在C#windows窗体的文本框中接受日期格式的值?

我在我的窗体中有一个字段,要求用户输入他们的出生日期...如何验证我的表单只接受数字和"/"(分隔符号)以及dd/mm/yyyy格式..还有一天应小于31,月份应小于12,年份不大于2012年

c# winforms

0
推荐指数
1
解决办法
2万
查看次数

C#为什么对象无法转换为int

我只是运动有一些问题..我必须编写一个程序,询问用户N的值,然后计算N!使用递归.我写了类似的东西

 namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This program will calculate a factorial of random number. Please type a number");
            String inputText = Console.ReadLine();
            int N = int.Parse(inputText);

String outputText = "Factorial of " + N + "is: "; int result = Count(ref N); Console.WriteLine(outputText + result); Console.ReadKey(); } private static object Count(ref int N) { for (int N; N > 0; N++) { return (N * N++); } } }
Run Code Online (Sandbox Code Playgroud)

问题在于"int result = Count(ref …

c#

-1
推荐指数
1
解决办法
445
查看次数

标签 统计

c# ×6

winforms ×3

.net ×1

generics ×1

list ×1

selectall ×1

textbox ×1