小编Rez*_*aei的帖子

DataGridViewComboBoxColumn - 必须单击两次单元格才能显示组合框

我正在使用a DataGridView,使用包含DataGridViewComboBoxColumn列的几列的设计器创建.

我必须点击每个单元格两次甚至三次以显示下拉列表,这有点令人恼火:

  1. 如果我点击文本部分,则需要3次点击!

在此输入图像描述 在此输入图像描述 在此输入图像描述

  1. 如果我点击下方的arroow,只需点击两下:

在此输入图像描述 在此输入图像描述

我认为这是由于单元格使用第一次点击来获得焦点,但有没有办法解决这个问题所以点击一个单元格会立即显示组合框?我注意到,使用DataGridViewCheckBoxColumn同样的问题没有不会发生......点击复选框立即切换它不管是细胞具有焦点.

.net c# datagridview winforms datagridviewcomboboxcolumn

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

如何在客户端上使用sql server数据库部署应用程序

我为我的客户设计了一个帐户软件.我使用Sql Server 2008数据库和存储过程.它是在Visual Studio 2010,dot net framework 3.0中开发的.我有超过500个客户端使用Windows 7.
主要问题是:

sql server运行时是否自动安装了dotnet框架?由于MS Access数据库不需要在客户端上安装Office.

我无法在每个客户端安装sql server 2008,这是一项艰巨的任务.客户也不熟悉安装过程.

如何在客户端上运行sql server数据库而不在客户端上安装它的设置?是否有任何运行时文件或设置?

.net c# sql-server deployment winforms

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

如何在继承的ControlDesigner类中获取ITypeDescriptorContext和IServiceProvider

我继承了ControlDesigner班级MyControlDesigner.

在这个类我需要获取后面的对象ITypeDescriptorContextIServiceProvider接口,但我不知道如何:(

我需要这两个接口在方法中传递它们,但我无法在任何其他对象中找到它们.

有人能帮帮我吗.

谢谢

最好的问候Bojan

.net c# user-controls windows-forms-designer winforms

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

在C#中编写表单时无法查看设计器

我正在关注winforms的这个教程,到目前为止,教程正在编写表单而不使用工具箱.我相信它很快就会更深入地介绍工具箱.

在本教程之后,我在以下两段代码中进行了部分类:

第一档:

using System;
using System.Windows.Forms;

public class Numeric : System.Windows.Forms.TextBox
{
    public Numeric()
    {
    }
}

public partial class Exercise
{
    private Numeric txtbox;
    System.ComponentModel.Container components;
}
Run Code Online (Sandbox Code Playgroud)

第二档:

using System;
using System.Windows.Forms;

public partial class Exercise : Form
{
    private void InitializeComponent()
    {
        txtbox = new Numeric();
        Controls.Add(txtbox);
    }

    public Exercise()
    {
        InitializeComponent();
    }
}

public class program
{
    public static int Main()
    {
        Application.Run(new Exercise());
        return 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我用F5运行代码时,一切看起来都很好:表单弹出文本框.

但出于某种原因,当我右键单击第二个文件并选择"视图设计器"时,我收到一条错误,上面写着"变量'txtbox'未声明或未被分配".我可以选择"忽略并继续",这会将我引导到一个没有文本框的表单.

为什么会这样?我知道有些人认为我应该使用工具箱,这可能是最明智的做法,但我仍然想知道为什么会这样.

.net c# windows-forms-designer visual-studio winforms

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

单击事件不触发 - 无法更改焦点 - 无法关闭表单

我有一个Windows窗体应用程序.我在这个应用程序中有几个表单(主表单和几个专门的表单),并且在一个表单上,单击事件不会触发我的任何按钮.

并不是处理程序中的代码被破坏了.这可以通过单击按钮时永远不会到达处理程序第一行的断点来确定.

其他事件正在发挥作用(我正在使用CheckedChanged此表单上的事件并且它们正在运行).

我的团队成员已经审核过,也无法发现问题.

这是我的代码的简化视图:

Designer生成代码

partial class MyForm
{
    private System.Windows.Forms.Button addButton;

    private void InitalizeComponent()
    {
        this.addButton = new System.Windows.Forms.Button();
        this.addButton.Name = "addButton";
        // Drawing statements here
        this.addButton.Click += new System.EventHandler(this.addButton_Click);

        this.Controls.Add(this.addButton);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的守则

public partial class MyForm : Form
{
    public MyForm()
    {
        InitializeComponent();
    }

    private void addButton_Click(object sender, EventArgs e)
    {
        MessageBox.Show("The debugger is not reaching a break point on this line");
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:测试的其他信息

我的表单中有几个数据绑定下拉列表.我发现如果我先在下拉框中进行选择,则只能触发click事件.

如果我没有选择,按钮处理程序中的断点将触发.否则它没有.这些下拉列表中未注册任何事件.

.net c# data-binding winforms

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

Windows表格工具箱未在VS 2015中显示

在我的Visual Studio 2015中,Windows窗体工具箱(我们有文本框,按钮等控件)没有显示出来.

我尝试检查Views-> ToolBars中的所有checke框,但没有用.

请帮忙.

谢谢,

visual-studio winforms visual-studio-2015

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

如何在用户控件 WinForm 中访问托管表单上的控件

在 Visual Studio 中,如何访问承载用户控件的表单上的控件?例如,当用户控件的文本框中的文本更改时,我希望另一个用户控件的另一个文本框中的文本更改。这两个用户控件都托管在同一个窗体上。提前致谢!

c# user-controls windows-forms-designer visual-studio winforms

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

带有实线边框的C#winforms按钮,如3d

如何创建带有实心边框(3d)的按钮,如下图C#winforms?

3D按钮

面板BorderStyle可以设置为Fixed3D,但按钮BorderStyle不能设置为Fixed3D.

我也尝试过FlatAppearance哪种是实用的扁平式.

c# button winforms

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

绘制后如何将圆圈视为控件? - 移动和选择形状

实际上,点击每个圆圈之后我想要改变它的颜色,例如,我希望它变成红色,总的来说,我想把它当作对照.

我知道如何在双击图片框时绘制代表图表节点的圆圈.我正在使用以下代码:

        public Form1()
    {
        InitializeComponent();

        pictureBox1.Paint += new PaintEventHandler(pic_Paint);
    }

    public Point positionCursor { get; set; }
    private List<Point> points = new List<Point>();
    public int circleNumber { get; set; }

    private void pictureBox1_DoubleClick(object sender, EventArgs e)
    {
        positionCursor = this.PointToClient(new Point(Cursor.Position.X - 25, Cursor.Position.Y - 25));

        points.Add(positionCursor);
        Label lbl = new Label();
        lbl.BackColor = Color.Transparent;
        lbl.Font = new Font("Arial", 7);

        lbl.Size = new Size(20, 15);

        if (circleNumber >= 10)
        {
            lbl.Location = new Point(points[circleNumber].X + 3, points[circleNumber].Y + 6); …
Run Code Online (Sandbox Code Playgroud)

.net c# gdi+ picturebox winforms

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

实体框架6错误serverversion:(System.Data.SqlClient.SqlConnection)customerOrderContext.Database.Connection).ServerVersion

我正在实现一个web api,它将使用实体框架6获取数据.我正在使用Sql Server 2014和visual studio 2015.While调试CustomerDao类中的代码我在customerOrderContext对象中看到一个异常,虽然我可以看到记录在客户对象中.然而,在使用块执行后,我无法看到任何记录.

((System.Data.SqlClient.SqlConnection)customerOrderContext.Database.Connection).ServerVersion

CustomerDao

using (var customerOrderContext = new Entities())
                {
                    return (from customer in customerOrderContext.Customers

                            select new CustomerOrder.BusinessObjects.Customers
                            {
                                Id = customer.Id,
                                FirstName = customer.FirstName,
                                LastName = customer.LastName,
                                Address = customer.Address,
                                City = customer.City,
                                Email = customer.Email,
                                Gender = customer.Gender,
                                State = customer.State,
                                Zip = customer.Zip
                            }).ToList();
                }
Run Code Online (Sandbox Code Playgroud)

配置文件中的连接字符串如下所示

<add name="Entities" connectionString="metadata=res://*/EF.CustomerOrderContext.csdl|res://*/EF.CustomerOrderContext.ssdl|res://*/EF.CustomerOrderContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Tom-PC\MSSQLSERVER2014;initial catalog=Ransang;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)

上下文类如下

public partial class Entities : DbContext
{
    public Entities()
        : base("name=Entities")
    {
    }

    protected override …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework asp.net-web-api entity-framework-6

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