【问题标题】:Calculate the textbox value based on the value of combobox ? ( wpf )根据组合框的值计算文本框的值? (wpf)
【发布时间】:2020-01-08 03:59:12
【问题描述】:

我有一个小程序,因为我是新手,我的程序是通过组合框选项将数据从 sql 服务器带到文本框,并使用该文本框中显示的值来计算 + 我已经到了放数据的步骤,现在感谢您帮助我在文本框中进行值计算,谢谢您的帮助。 xml代码:

<Window x:Class="comboboxapp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:comboboxapp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <Window.Resources>
        <local:SimpleMath x:Key="MyFriends"/>
    </Window.Resources>

    <Grid>
        <Label Content="code" HorizontalAlignment="Left" Margin="38,52,0,0" 
               VerticalAlignment="Top" Width="46" Height="23"/>
        <Label Content="pieces" HorizontalAlignment="Left" Margin="38,126,0,0" 
               VerticalAlignment="Top" Width="46" Height="23"/>
        <Label Content="layers" HorizontalAlignment="Left" Margin="38,196,0,0" 
               VerticalAlignment="Top" Width="46" Height="30"/>
        <Label Content="production pieces" HorizontalAlignment="Left" 
               Margin="0,278,0,0" VerticalAlignment="Top" Width="108" Height="25"/>
        <TextBox x:Name="txtcode" 
                 Text="{Binding Txtcode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="23" Margin="124,52,0,0" 
                 TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtpieces" 
                 Text="{Binding Txtpieces, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="23" 
                 Margin="124,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtlayers" 
                 Text="{Binding Txtlayers,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="23" 
                 Margin="124,203,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtproductionpieces" 
                 Text="{Binding Txtproductionpieces,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="23" Margin="124,280,0,0" 
                 TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <ComboBox x:Name="comboBox1" ItemsSource="{Binding Source={StaticResource MyFriends}}" 
                  HorizontalAlignment="Left" Margin="418,52,0,0" VerticalAlignment="Top" 
                  Width="319" Height="36" SelectionChanged="ComboBox1_SelectionChanged"/>
        <TextBox x:Name="txtseccond" 
                 Text="{Binding Txtseccond,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="23" 
                 Margin="124,345,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <Label Content="seccond" HorizontalAlignment="Left" Margin="38,345,0,0" 
               VerticalAlignment="Top" Width="46" Height="23"/>
        <TextBlock Text="{Binding A, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" 
                   HorizontalAlignment="Left" Margin="418,133,0,0" TextWrapping="Wrap"  
                   VerticalAlignment="Top" Height="23" Width="248"/>
        <TextBox Text="{Binding No1,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" 
                 HorizontalAlignment="Left" Height="21" Margin="426,210,0,0" 
                 TextWrapping="Wrap" VerticalAlignment="Top" Width="303"/>
    </Grid>
</Window>

C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace comboboxapp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public SimpleMath Formular { get; set; }
        public object SelectedValue { get; private set; }

        public MainWindow()
        {
            Formular = new SimpleMath()
            {
                Txtcode = 0,
                Txtpieces = 0,
                Txtlayers = 0,
                Txtproductionpieces = 0,
                Txtseccond = 0,

            };
            InitializeComponent();
            DataContext = Formular;
            Fillcombobox();
        }
        private void MainWindow_Load(object sender, EventArgs e) 
        {

        }
        public void Fillcombobox()
        {
            SqlConnection con = new SqlConnection("Data Source=LEAN-22\\SQLEXPRESS;Initial 
Catalog=LUAT;Integrated Security=True");

            string sql = " select * from comboboxnew ";
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataReader myreader;
            try
            {
                con.Open();
                myreader = cmd.ExecuteReader();
                while (myreader.Read())
                {
                    string sname = myreader.GetInt32(0).ToString();
                    comboBox1.Items.Add(sname);

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
        public class SimpleMath : INotifyPropertyChanged
        {
            private int no1;

            public int No1
            {
                get { return no1; }
                set
                {
                    no1 = value;
                    OnPropertyChanged("No1");
                    OnPropertyChanged("A");
                }
            }
            private int txtcode;

            public int Txtcode
            {
                get { return txtcode; }
                set
                {
                    txtcode = value;
                    OnPropertyChanged("Txtcode");
                    OnPropertyChanged("A");
                }
            }
            private int txtpieces;

            public int Txtpieces
            {
                get { return txtpieces; }
                set
                {
                    txtpieces = value;
                    OnPropertyChanged("Txtcode");
                    OnPropertyChanged("A");
                }
            }
            private int txtlayers;

            public int Txtlayers
            {
                get { return txtlayers; }
                set
                {
                    txtlayers = value;
                    OnPropertyChanged("Txtlayers");
                    OnPropertyChanged("A");
                }
            }
            private int txtproductionpieces;

            public int Txtproductionpieces
            {
                get { return txtproductionpieces; }
                set
                {
                    txtproductionpieces = value;
                    OnPropertyChanged("Txtproductionpieces");
                    OnPropertyChanged("A");
                }
            }
            private int txtseccond;

            public int Txtseccond
            {
                get { return txtseccond; }
                set
                {
                    txtseccond = value;
                    OnPropertyChanged("Txtseccond");
                    OnPropertyChanged("A");
                }
            }
            public double A => No1;

            public event PropertyChangedEventHandler PropertyChanged;
            public void OnPropertyChanged([CallerMemberName()] string propertyName = null)
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        private void ComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            SqlConnection con = new SqlConnection("Data Source=LEAN-22\\SQLEXPRESS;Initial 
Catalog=LUAT;Integrated Security=True");
            //  string sql = " select * from comboboxnew where code = '" + comboBox1.Text+ "';";
            string sql = " select * from comboboxnew where code = '" + comboBox1.SelectedItem + 
"';";
            //Console.WriteLine(comboBox1.Text);
            //MessageBox.Show(comboBox1.Text);
            SqlCommand cmd = new SqlCommand(sql, con); 
            SqlDataReader myreader; 
            try
            {
                con.Open();
                myreader = cmd.ExecuteReader();
                while (myreader.Read())
                {
                    string code = myreader.GetInt32(0).ToString();
                    string pieces = myreader.GetInt32(1).ToString();
                    string layers = myreader.GetInt32(2).ToString();
                    string productionpieces = myreader.GetInt32(3).ToString();
                    string seccond = myreader.GetInt32(4).ToString();
                     txtcode.Text = code;
                    //txtcode.Text =SelectedValue;
                    txtpieces.Text = pieces;
                      //txtpieces.Text = "New value";
                    txtlayers.Text = layers;
                       //txtlayers.Text = "New value";
                    txtproductionpieces.Text = productionpieces;
                     //txtproductionpieces.Text = "New value";
                    txtseccond.Text = seccond;
                    //txtseccond.Text = "New value";

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}  

【问题讨论】:

  • 你想将这些值相加并显示在TextBox中吗?
  • 示例:如果我想要 caculator 1 value Textbox 从 5 textbox 中获取并显示此文本框?文本框 =( textbox1 - textbox2) /textbox3 ?
  • 公共双A => No1;做不到

标签: c# wpf combobox textbox


【解决方案1】:

据我了解,您只是想将这五个值加到TextBox 中,对吗?

如果是这样,您可以通过多种方式做到这一点...

一个: 在SimpleMath 类中有一个属性,它是其他值的总和,并将其绑定到TextBox。每当这五个其他属性中的任何一个更新时,您都必须更新 sum 属性。

两个: 您可以使用IMultiValueConverter 对值求和,而SimpleMath 类中没有更多属性。这样做是这样的:

您创建一个实现IMultiValueConverter 接口的类

public class SumConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        return values.Cast<int>()?.Sum()?.ToString();
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        return null;
    }
}

并像这样在 XAML 中使用它

<TextBox>
    <TextBox.Resources>
        <local:SumConverter x:Key="SumConverter"/>
    </TextBox.Resources>
    <TextBox.Text>
        <MultiBinding Converter="{StaticResource SumConverter}">
            <Binding Path="Text" ElementName="OtherTextBox1" />
            <Binding Path="Text" ElementName="OtherTextBox2" />
            <Binding Path="Text" ElementName="OtherTextBox3" />
            <Binding Path="Text" ElementName="OtherTextBox4" />
            <Binding Path="Text" ElementName="OtherTextBox5" />
        </MultiBinding>
    </TextBox.Text>
</Control>

希望对你有帮助

编辑

我已经制作了一个测试项目,向您展示我建议的两个解决方案的完整代码,这里是:

解决方案一

using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;

namespace StackOverflowTest
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new SimpleMath();
        }
    }

    public class SimpleMath : INotifyPropertyChanged
    {
        private int _numberOne;
        public int NumberOne
        {
            get => _numberOne;
            set
            {
                _numberOne = value;
                OnPropertyChanged();
                CalculateSum();
            }
        }

        private int _numberTwo;
        public int NumberTwo
        {
            get => _numberTwo;
            set
            {
                _numberTwo = value;
                OnPropertyChanged();
                CalculateSum();
            }
        }

        private int _numberThree;
        public int NumberThree
        {
            get => _numberThree;
            set
            {
                _numberThree = value;
                OnPropertyChanged();
                CalculateSum();
            }
        }

        private int _numberSum;
        public int NumberSum
        {
            get => _numberSum;
            set
            {
                _numberSum = value;
                OnPropertyChanged();
            }
        }

        private void CalculateSum()
        {
            NumberSum = NumberOne + NumberTwo + NumberThree;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged([CallerMemberName()] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
<Window x:Class="StackOverflowTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:StackOverflowTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="200" Width="200">
    <StackPanel>
        <TextBox x:Name="TxtOne" HorizontalAlignment="Stretch" Text="{Binding NumberOne}" Margin="10,10,10,0"/>
        <TextBox x:Name="TxtTwo" HorizontalAlignment="Stretch" Text="{Binding NumberTwo}" Margin="10,10,10,0"/>
        <TextBox x:Name="TxtThree" HorizontalAlignment="Stretch" Text="{Binding NumberThree}" Margin="10,10,10,0"/>

        <TextBlock HorizontalAlignment="Center" Text="{Binding NumberSum}" Margin="10,10,10,0"/>
    </StackPanel>
</Window>

解决方案二

using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Data;
using System.Collections.Generic;

namespace StackOverflowTest
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new SimpleMath();
        }
    }

    public class SimpleMath : INotifyPropertyChanged
    {
        private int _numberOne;
        public int NumberOne
        {
            get => _numberOne;
            set
            {
                _numberOne = value;
                OnPropertyChanged();
            }
        }

        private int _numberTwo;
        public int NumberTwo
        {
            get => _numberTwo;
            set
            {
                _numberTwo = value;
                OnPropertyChanged();
            }
        }

        private int _numberThree;
        public int NumberThree
        {
            get => _numberThree;
            set
            {
                _numberThree = value;
                OnPropertyChanged();
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged([CallerMemberName()] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public class SumConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var numbers = new List<int>();
            foreach (var item in values)
            {
                if(item is string stringValue)
                {
                    try
                    {
                        numbers.Add(System.Convert.ToInt32(stringValue));
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Oops, not a number...");
                    }
                }
            }

            return numbers.Sum().ToString();
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
<Window x:Class="StackOverflowTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:StackOverflowTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="200" Width="200">
    <StackPanel>
        <TextBox x:Name="TxtOne" HorizontalAlignment="Stretch" Text="{Binding NumberOne}" Margin="10,10,10,0"/>
        <TextBox x:Name="TxtTwo" HorizontalAlignment="Stretch" Text="{Binding NumberTwo}" Margin="10,10,10,0"/>
        <TextBox x:Name="TxtThree" HorizontalAlignment="Stretch" Text="{Binding NumberThree}" Margin="10,10,10,0"/>

        <TextBlock HorizontalAlignment="Center" Margin="10,10,10,0">
            <TextBlock.Resources>
                <local:SumConverter x:Key="SumConverter"/>
            </TextBlock.Resources>
            <TextBlock.Text>
                <MultiBinding Converter="{StaticResource SumConverter}">
                    <Binding Path="Text" ElementName="TxtOne" />
                    <Binding Path="Text" ElementName="TxtTwo" />
                    <Binding Path="Text" ElementName="TxtThree" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </StackPanel>
</Window>

它是这样的

【讨论】:

  • 示例:如果我想要 caculator 1 value Textbox 从 5 textbox 中获取并显示此文本框?文本框 =( textbox1 - textbox2) /textbox3 ?
  • 这正是我回复的代码应该做的。是你要找的吗?
  • 在 SimpleMath 类中,它是其他值的总和,并将其绑定到 TextBox 但我无法计算它 EX: ( public double A => textbox1 +2 ; )
  • 公共双A => No1;做不到
  • 我已编辑我的答案以显示两个建议解决方案的完整代码。它应该向您展示如何绑定总和值。
【解决方案2】:

计算器无法显示文本框总和 c#代码:

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace comboboxapp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
           public MainWindow()
        { 
            InitializeComponent();
            this.DataContext = new SimpleMath();
             Fillcombobox();
        }
            private void MainWindow_Load(object sender, EventArgs e)
            {

            }
            public void Fillcombobox()
            {
            SqlConnection con = new SqlConnection("Data Source=LEAN-22\\SQLEXPRESS;Initial Catalog=LUAT;Integrated Security=True") ;

                string sql = " select * from comboboxnew ";
                SqlCommand cmd = new SqlCommand(sql, con);
                SqlDataReader myreader;
                try
                {
                    con.Open();
                    myreader = cmd.ExecuteReader();
                    while (myreader.Read())
                    {
                        string sname = myreader.GetInt32(0).ToString();
                        comboBox1.Items.Add(sname);

                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                }
            }
        public class SimpleMath : INotifyPropertyChanged
        {
            private int _no1;

            public int No1
            {
                get => _no1;
                set
                {
                    _no1 = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");
                }
            }
            private int _txtcode;

            public int Txtcode
            {
                get => _txtcode;
                set
                {
                    _txtcode = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");
                }
            }
            private int _txtpieces;

            public int Txtpieces
            {
                get => _txtpieces;
                set
                {
                    _txtpieces = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");

                }
            }
            private int _txtlayers;

            public int Txtlayers
            {
                get => _txtlayers;
                set
                {
                    _txtlayers = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");

                }
            }
            private int _txtproductionpieces;

            public int Txtproductionpieces
            {
                get => _txtproductionpieces;
                set
                {
                    _txtproductionpieces = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");

                }
            }
            private int _txtseccond;

            public int Txtseccond
            {
                get => _txtseccond;
                set
                {
                    _txtseccond = value;
                    OnPropertyChanged();
                    CalculateSum();
                    OnPropertyChanged("A");

                }
            }
            private int a;
            public int A
            {
                get => a;
                set
                {
                    a = value;
                    OnPropertyChanged();
                }
            }
            private void CalculateSum()
            {
                A = Txtcode + Txtlayers + Txtpieces;
            }
            public event PropertyChangedEventHandler PropertyChanged;
            public void OnPropertyChanged([CallerMemberName()] string propertyName = null)
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        private void ComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {


            SqlConnection con = new SqlConnection("Data Source=LEAN-22\\SQLEXPRESS;Initial Catalog=LUAT;Integrated Security=True");
            //  string sql = " select * from comboboxnew where code = '" + comboBox1.Text+ "';";
            string sql = " select * from comboboxnew where code = '" + comboBox1.SelectedItem + "';";

            //Console.WriteLine(comboBox1.Text);
            //MessageBox.Show(comboBox1.Text);
            SqlCommand cmd = new SqlCommand(sql, con); 
            SqlDataReader myreader; 
            try
            {

                con.Open();
                myreader = cmd.ExecuteReader();
                while (myreader.Read())
                {

                    string code = myreader.GetInt32(0).ToString();
                    string pieces = myreader.GetInt32(1).ToString();
                    string layers = myreader.GetInt32(2).ToString();
                    string productionpieces = myreader.GetInt32(3).ToString();
                    string seccond = myreader.GetInt32(4).ToString();

                    txtcode.Text = code;

                    txtpieces.Text = pieces;

                    txtlayers.Text = layers;

                    txtproductionpieces.Text = productionpieces;

                    txtseccond.Text = seccond;




            }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

    }
}  

xaml 代码:

    <Window x:Class="comboboxapp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:comboboxapp1"
        xmlns:dxa="http://schemas.devexpress.com/winfx/2008/xaml/accordion" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" 
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
      <Grid>
        <Label Content="code" HorizontalAlignment="Left" Margin="38,52,0,0" VerticalAlignment="Top" Width="46" Height="23"/>
        <Label Content="pieces" HorizontalAlignment="Left" Margin="38,126,0,0" VerticalAlignment="Top" Width="46" Height="23"/>
        <Label Content="layers" HorizontalAlignment="Left" Margin="38,196,0,0" VerticalAlignment="Top" Width="46" Height="30"/>
        <Label Content="production pieces" HorizontalAlignment="Left" Margin="0,278,0,0" VerticalAlignment="Top" Width="108" Height="25"/>
        <TextBox x:Name="txtcode" Text="{Binding Txtcode, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="23" Margin="124,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtpieces" Text="{Binding Txtpieces, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="23" Margin="124,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtlayers" Text="{Binding Txtlayers,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="23" Margin="124,203,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <TextBox x:Name="txtproductionpieces" Text="{Binding Txtproductionpieces,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="23" Margin="124,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <ComboBox x:Name="comboBox1" Text="{Binding combobox1,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Margin="418,52,0,0" VerticalAlignment="Top" Width="319" Height="36" SelectionChanged="ComboBox1_SelectionChanged"/>
        <TextBox x:Name="txtseccond" Text="{Binding Txtseccond,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  HorizontalAlignment="Left" Height="23" Margin="124,345,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
        <Label Content="seccond" HorizontalAlignment="Left" Margin="38,345,0,0" VerticalAlignment="Top" Width="46" Height="23"/>
        <TextBlock Text="{Binding A, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"  HorizontalAlignment="Left" Margin="418,133,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Height="23" Width="248"/>
        <TextBox Text="{Binding No1,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="21" Margin="426,210,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="303"/>


    </Grid>
</Window>

我的数据 sql: enter image description here

【讨论】:

    猜你喜欢
    • 2020-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多