小编Pri*_*ner的帖子

按数字突出显示字符

考虑使用以下字符串及其数值:

在此输入图像描述

然后,您允许用户键入文本框:1|17|7|19,如何突出显示文本,如下所示:

在此输入图像描述

我可以在空格和段落中计算它,但是当我完全删除所有空格和新行(例如"Thisissomedummytext")时,我无法弄清楚如何实现这一点.

编辑

是我到目前为止,它考虑了空格和新行(nl的计数为1个字符).

javascript jquery

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

背景工作者访问UI的正确方法

我不确定我是否正确地执行此操作,但是我使用了以下代码(单击button1,执行_DoWork).问题是:如何调用UI来获取textbox1和textbox2的值,因为它们不能被调用,因为它们位于不同的线程上.我应该使用调度员吗?

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        if (textBox1.Text == "")
        {
            MessageBox.Show("Please enter a username and password", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
        else
        {
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.RunWorkerAsync();
        }
    }

    private void bw_DoWork(object sender, DoWorkEventArgs e)
    {
        Console.WriteLine("asd");
        UserManagement um = new UserManagement(sm.GetServerConnectionString());
        if (um.AuthUser(textBox1.Text, textBox2.Password))
        {
            MainWindow mw = new MainWindow();
            mw.Show();
            this.Close();
        }
        else
        {
            if (um.Timeout)
            {
                MessageBox.Show("Could not connect to server, please check your configuration", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                MessageBox.Show("Incorrect username or …
Run Code Online (Sandbox Code Playgroud)

c# wpf backgroundworker

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

PHP - 从字符串创建数组

我有一个看起来像这样的字符串:

single=Single&multiple=Multiple2&check=check1&radio=radio2

我怎么能这样创建一个数组:

array(
  'single' => 'Single',
  'multiple' => 'Multiple2',
  'check' => 'check1',
  'radio' => 'radio2',
)
Run Code Online (Sandbox Code Playgroud)

php regex arrays string

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

LINQ to SQL connectionstring

我有一个应用程序,我希望能够为我的LINQ to SQL配置连接字符串.我已经尝试了很多不同的方法,但似乎无法让它发挥作用.我想在运行应用程序时在代码中动态执行此操作,原因是用户可以更改连接设置.

如果我从app.config中删除connectionString,应用程序仍然正常(通信),这让我想知道我应该在哪里更改连接字符串?

c# wpf linq-to-sql

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

在DataGrid单元格中添加一个小的彩色矩形

我想在我的DataGrid中添加一个小的(10x10)矩形作为单元格.我已经在对象中设置了它,我只是想找到一种从代码到我的DataGrid的方法.

这是我的DataGrid XAML:

<DataGrid Name="dataGrid1" Grid.Row="2" AutoGenerateColumns="False" DataContext="{Binding}" HeadersVisibility="Column" 
              HorizontalGridLinesBrush="#ccc" VerticalGridLinesBrush="#ccc" VirtualizingStackPanel.VirtualizationMode="Standard" Background="#FFF6F6F6" CanUserAddRows="False">
        <DataGrid.Resources>
            <ResourceDictionary Source="Pages/DataGridStyle.xaml" />
        </DataGrid.Resources>
        <DataGrid.Columns>
            <!-- In here I would like a datagrid cell that is just a 10x10 box which uses {Binding Path=TemplateCellColour} (templatecellcolour is stored as a brush, is this an issue? -->
            <DataGridTextColumn ElementStyle="{StaticResource CenterTextCell}" Width="0.5*" Binding="{Binding Path=TemplateCellID}" Header="ID"></DataGridTextColumn>
            <DataGridTextColumn ElementStyle="{StaticResource CenterTextCell}" Width="1*" Binding="{Binding Path=CellWidth}" Header="Width"></DataGridTextColumn>
            <DataGridTextColumn ElementStyle="{StaticResource CenterTextCell}" Width="1*" Binding="{Binding Path=CellHeight}" Header="Height"></DataGridTextColumn>
            <DataGridTextColumn ElementStyle="{StaticResource CenterTextCell}" Width="1*" Binding="{Binding Path=CellTop}" Header="Top"></DataGridTextColumn>
            <DataGridTextColumn ElementStyle="{StaticResource …
Run Code Online (Sandbox Code Playgroud)

.net wpf datagrid

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

检索firebase服务器时间而不先设置它

有没有办法获得服务器时间而无需先设置它?例如,我可以简单地做:

curl -X PUT -d '{".sv": "timestamp"}' https://SampleChat.firebaseIO-demo.com/servertime.json
Run Code Online (Sandbox Code Playgroud)

这将返回服务器时间,但这会servertime在我的firebase实例中设置值.我应该注意到我正在使用REST API.

php firebase

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

jQuery AutoComplete,自定义返回数据

我正在尝试创建一个自动完成的框,由于返回自定义数据而遇到问题,我似乎无法填充自动完成框.

这是数据(JSON):

[{"user_id":"1","user_name":"jarru"},{"user_id":"2","user_name":"harryq"},{"user_id":"3","user_name":"sleet"}]
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的javascript:

<script type="application/javascript">
$(document).ready(function(){
    $("#add_email_user").autocomplete({
            source: baseurl+"users/ajax/users/",
                        dataType: 'json',
                        success: function(data) {
                        console.log("asd");
                          response($.map(data, function(item) {
                            return {
                              label: item.user_name,
                              value: item.user_id
                            }
                          }));
                          }
        });

});
</script>
Run Code Online (Sandbox Code Playgroud)

当我使用这个代码时,没有任何反应,大约有3px的下拉列表中没有任何内容.正确请求数据(由FireBug控制台报告),但下拉列表中没有任何内容.

jquery json jquery-ui

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

HTML/CSS:Webkit浏览器切断斜体链接

我拥有的
是一个普通的HTML链接,比如<a href="#">Link</a>.在我的样式表中,我已经设置了该链接,display: inline-block;因为我必须将它推到一点以匹配布局.
font-style设置为italic.

问题
这会导致以下问题:由于文本以斜体显示,因此链接词的最后一个字母超出了链接周围的框.正因为如此,Safari和Chrome在悬停时"切断"了颜色变化.查看截图,我为链接指定了背景颜色,以使其更清晰.
在此输入图像描述
正常链接颜色是浅色,蓝色是悬停颜色.

Firefox无需削减任何内容即可正确管理.

为链接设置填充可能是最简单的解决方案,但我觉得对我来说是一种解决方法.还有其他解决方案吗?

小提琴: http ://jsfiddle.net/qD78e/

html css hyperlink hover

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

多页WPF应用程序

我是桌面应用程序开发的新手,并且有一个非常基本的问题.我有一个名为MainWindow的WPF表单,我应该如何在此处使用多个页面,例如"用户管理","管理内容"等.

我想我有以下选择:

  1. 使用多种形式
  2. 标签
  3. 集团箱?

任何澄清都会很棒!

c# windows wpf

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

如何遍历$ _FILES?

我想在$ _FILES []数组周围添加循环。我尝试过$count= count($_FILES['files'][name]),然后在其周围添加循环 for($i=0; $i<=$count; $i++),但是并没有给我想要的输出。

我只想从用户上传的文件中添加循环,现在它正在计算表单中所有可用的“文件”。

请告诉我一种仅计算上传文件并循环浏览的方法。

html php file

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