小编ijb*_*109的帖子

在.NET图表中仅使用X轴中的自定义标签

我在C#中创建一个.NET线图,X轴间隔为几周.对于我的项目,我只想使用自定义标签,但是现在我仍然需要网格线.有没有人知道在保留自定义标签的同时隐藏默认X轴标签的方法?

我试过这个:

Chart4.ChartAreas[0].AxisX.LabelStyle.Enabled = false;
Run Code Online (Sandbox Code Playgroud)

显而易见的结果是没有应用标签,这不是我想要做的.

编辑: 生成原始行的代码是这样的:

Chart4.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "M";
Run Code Online (Sandbox Code Playgroud)

自定义标签的代码是这样的:

int month = XValues[0].Month;
var XAxis = Chart4.ChartAreas[0].AxisX;

DateTime StartMonthPos = XValues[0];
DateTime EndPos = new DateTime();

foreach (DateTime Date in XValues)
{
    EndPos = Date;

    if (Date.Month != month)
    {
        Chart4.ChartAreas[0].AxisX.CustomLabels.Add(StartMonthPos.ToOADate(), EndPos.ToOADate(), StartMonthPos.ToString("MMMM"), 1, LabelMarkStyle.None);
        StartMonthPos = Date;
    }

    month = Date.Month;
}

XAxis.CustomLabels.Add(StartMonthPos.ToOADate(), EndPos.ToOADate(), StartMonthPos.ToString("MMMM"), 1, LabelMarkStyle.None);
Run Code Online (Sandbox Code Playgroud)

该图表如下所示: 带有日期的图表

它看起来应该是这样的: 没有约会的图表

.net c# charts linechart axis-labels

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

后台工作人员总是很忙

我对使用事件处理程序和后台工作人员不熟悉,所以我可能会在这里遗漏一些完全明显的东西。尽管如此,我两天来一直在努力解决这个问题,所以我想我不妨看看有人说了什么。

我有一个名为 SqlExpressDownloader 的后台工作者。它在我的程序开始时开始运行,其余工作运行,然后它应该等待方法中的操作SqlExpressDownloader_DoWork()完成才能继续。唯一的问题是,由于某种原因,每当我这样做时while(SqlExpressDownloader.IsBusy),它总是响应为忙碌,因此将永远等待。

事件处理程序的代码在这里:

    private void SqlExpressDownloader_DoWork(object sender, DoWorkEventArgs e)
    {
        string sSource = string.Format("{0}\\{1}", Paths.Settings_Common, "sqlexpr_x64_enu.exe");
        Debug.WriteLine(sSource);
        Debug.WriteLine("http://www.elexioamp.com/Install/redistributables/sql2008r2express/sqlexpr_x64_enu.exe");
        if (!System.IO.File.Exists(sSource))
        {
            WebClient oWebClient = new WebClient();
            oWebClient.DownloadProgressChanged += DownloadProgressChanged;
            oWebClient.DownloadDataCompleted += DownloadComplete;

            oWebClient.DownloadFileAsync(new System.Uri("http://www.elexioamp.com/Install/redistributables/sql2008r2express/sqlexpr_x64_enu.exe"), sSource);

            while (oWebClient.IsBusy)
            {
                Thread.Sleep(100);
            }

            e.Result = "";
            DownloadFinished = true;
        }
    }
Run Code Online (Sandbox Code Playgroud)

我看过代码,也看过它完成这个方法。我什至return在之后添加了一个DownloadFinished = true,但它仍然响应为忙。我想知道的是如何让后台工作人员响应不忙。

编辑事件全部添加到构造函数中,如下所示:

        SqlExpressDownloader = new BackgroundWorker();
        SqlExpressDownloader.DoWork += new DoWorkEventHandler(this.SqlExpressDownloader_DoWork);
        SqlExpressDownloader.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.SqlExpressDownloader_RunWorkerCompleted);
Run Code Online (Sandbox Code Playgroud)

看起来RunWorkerCompleteEventHandler像这样:

    private void SqlExpressDownloader_RunWorkerCompleted(object …
Run Code Online (Sandbox Code Playgroud)

c# event-handling backgroundworker

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

文本溢出:Internet Explorer 中的换行符后省略号不起作用

我有一个问题text-overflow: ellipsis当文本由换行符分隔时,

在 Firefox 和 Chrome 中,两行文本都会被省略号截断。在 Internet Explorer 中,第一行被省略号截断,第二行仅在右侧截断。

这是我的代码:

.text-wrapper {
  border: solid 1px #C2C2C2;
  padding:10px;
}
.text-wrapper p{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud)
<div class="text-wrapper" style="width:250px;">

    <p>
      This line overflows and gets an ellipsis in any browser. 
      <br/>
      This line overflows and gets an ellipsis in any browser except IE.
    </p>

</div>
Run Code Online (Sandbox Code Playgroud)

html css internet-explorer cross-browser

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