как получить данные из датагрида?
XML-код со списком:
я подключаю комбо к таблице MahName
combobox1.ItemsSource = database.Mahs.ToList();
combobox1.DisplayMemberPath = "MahName";
это датагрид кода
<DataGrid.Columns>
<DataGridTextColumn Header = "کد محصول" Binding = "{Binding MahID}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام محصول" Binding = "{Binding MahName}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت فروش" Binding = "{Binding MahFe}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده اول" Binding = "{Binding Mah1}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده دوم" Binding = "{Binding Mah2}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده سوم" Binding = "{Binding Mah3}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده چهارم" Binding = "{Binding Mah4}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده پنجم" Binding = "{Binding Mah5}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده ششم" Binding = "{Binding Mah6}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده هفتم" Binding = "{Binding Mah7}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده هشتم" Binding = "{Binding Mah8}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده نهم" Binding = "{Binding Mah9}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "نام ماده دهم" Binding = "{Binding Mah10}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده اول" Binding = "{Binding Mahg1}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده دوم" Binding = "{Binding Mahg2}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده سوم" Binding = "{Binding Mahg3}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده چهارم" Binding = "{Binding Mahg4}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده پنجم" Binding = "{Binding Mahg5}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده ششم" Binding = "{Binding Mahg6}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده هفتم" Binding = "{Binding Mahg7}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده هشتم" Binding = "{Binding Mahg8}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده نهم" Binding = "{Binding Mahg9}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "وزن ماده دهم" Binding = "{Binding Mahg10}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده اول" Binding = "{Binding Mahf1}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده دوم" Binding = "{Binding Mahf2}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده سوم" Binding = "{Binding Mahf3}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده چهارم" Binding = "{Binding Mahf4}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده پنجم" Binding = "{Binding Mahf5}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده ششم" Binding = "{Binding Mahf6}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده هفتم" Binding = "{Binding Mahf7}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده هشتم" Binding = "{Binding Mahf8}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = " قیمت ماده نهم" Binding = "{Binding Mahf9}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header = "سود" Binding = "{Binding Mahd}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType = "{x:Type DataGridColumnHeader}">
<Setter Property = "FontFamily" Value = "B Yekan" />
<Setter Property = "FontSize" Value = "12" />
<Setter Property = "HorizontalContentAlignment" Value = "Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
я хочу, когда combobox.text = "MahName" в сетке данных, затем "Mahg1" в сетке данных/1000, затем * "Mahf1" в сетке данных ...
«Mahg10» в сетке данных /1000, затем * «Mah10» в сетке данных
Mahf — это цена, а Mahg — это вес.
что я должен делать?
Пожалуйста, уточните свой вопрос (я понятия не имею, что означает «datagrid/1000 then *»). И удалите любой код, который не имеет прямого отношения к вашему вопросу.
@redcurry забудь обо всем. как я могу получить данные из сетки данных, когда текст поля со списком равен записи таблицы данных





Никто не может мне помочь?