Soran
5 tane formdaki radiobutton seçimlerinden aldığım sonuçları son formdaki 5 tane textboa yazdırıp dataviewgrid'e aktardım.Bu forma;5 tane formdaki 5 picture box ı nasıl dataviewgrid e ekleyebilirim?

Soru
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication42
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
DataTable tablo = new DataTable();
DataGridViewImageColumn img = new DataGridViewImageColumn();
static public string ürün1;
static public string ürün2;
static public string ürün3;
static public string ürün4;
static public string ürün5;
private void Form7_Load(object sender, EventArgs e)
{
tablo.Columns.Add("1.ürün", typeof(string));
tablo.Columns.Add("2.ürün:", typeof(string));
tablo.Columns.Add("3.ürün:", typeof(string));
tablo.Columns.Add("4.ürün:", typeof(string));
tablo.Columns.Add("5.ürün:", typeof(string));//hep string olarak tanımlandı işleme sokmak istersek convert edeceğiz.
dataGridView1.DataSource = tablo;
if (ürün1=="Hurda")
{
textBox11000.Text = "Hurda";
}
if (ürün1 == "Satışa çıksın")
{
textBox11000.Text = "Satışa çıksın";
}
if (ürün1 == "Bloke stok")
{
textBox11000.Text = "Bloke stok";
}
if (ürün2 == "Hurda")
{
textBox12000.Text = "Hurda";
}
if (ürün2 == "Satışa çıksın")
{
textBox12000.Text = "Satışa çıksın";
}
if (ürün2 == "Bloke stok")
{
textBox12000.Text = "Bloke stok";
}
if (ürün3 == "Hurda")
{
textBox13000.Text = "Hurda";
}
if (ürün3 == "Satışa çıksın")
{
textBox13000.Text = "Satışa çıksın";
}
if (ürün3 == "Bloke stok")
{
textBox13000.Text = "Bloke stok";
}
if (ürün4 == "Hurda")
{
textBox14000.Text = "Hurda";
}
if (ürün4 == "Satışa çıksın")
{
textBox14000.Text = "Satışa çıksın";
}
if (ürün4 == "Bloke stok")
{
textBox14000.Text = "Bloke stok";
}
if (ürün5 == "Hurda")
{
textBox15000.Text = "Hurda";
}
if (ürün5 == "Satışa çıksın")
{
textBox15000.Text = "Satışa çıksın";
}
if (ürün5 == "Bloke stok")
{
textBox15000.Text = "Bloke stok";
}
}
private void button100000_Click(object sender, EventArgs e)
{
tablo.Rows.Add(textBox11000.Text, textBox12000.Text, textBox13000.Text, textBox14000.Text, textBox15000.Text);
dataGridView1.DataSource = tablo;
}
}
}
Tüm Yanıtlar
-
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form7 : Form { public Form7() { InitializeComponent(); } DataTable tablo = new DataTable(); static public string urun1; static public string urun2; static public string urun3; static public string urun4; static public string urun5; private void Form7_Load(object sender, EventArgs e) { } private void button100000_Click(object sender, EventArgs e) { urun1 = textBox11000.Text; urun2 = textBox12000.Text; urun3 = textBox13000.Text; urun4 = textBox14000.Text; urun5 = textBox15000.Text; if (urun1 == "Hurda") { textBox11000.Text = "Hurda"; } if (urun1 == "Satışa çıksın") { textBox11000.Text = "Satışa çıksın"; } if (urun1 == "Bloke stok") { textBox11000.Text = "Bloke stok"; } if (urun2 == "Hurda") { textBox12000.Text = "Hurda"; } if (urun2 == "Satışa çıksın") { textBox12000.Text = "Satışa çıksın"; } if (urun2 == "Bloke stok") { textBox12000.Text = "Bloke stok"; } if (urun3 == "Hurda") { textBox13000.Text = "Hurda"; } if (urun3 == "Satışa çıksın") { textBox13000.Text = "Satışa çıksın"; } if (urun3 == "Bloke stok") { textBox13000.Text = "Bloke stok"; } if (urun4 == "Hurda") { textBox14000.Text = "Hurda"; } if (urun4 == "Satışa çıksın") { textBox14000.Text = "Satışa çıksın"; } if (urun4 == "Bloke stok") { textBox14000.Text = "Bloke stok"; } if (urun5 == "Hurda") { textBox15000.Text = "Hurda"; } if (urun5 == "Satışa çıksın") { textBox15000.Text = "Satışa çıksın"; } if (urun5 == "Bloke stok") { textBox15000.Text = "Bloke stok"; } DataGridViewTextBoxColumn dturun1 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn dturun2 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn dturun3 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn dturun4 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn dturun5 = new DataGridViewTextBoxColumn(); DataGridViewImageColumn resim = new DataGridViewImageColumn(); // Datagride alanlarımızı ekliyoruz. dataGridView1.Columns.Add(dturun1); dataGridView1.Columns.Add(dturun2); dataGridView1.Columns.Add(dturun3); dataGridView1.Columns.Add(dturun4); dataGridView1.Columns.Add(dturun5); dataGridView1.Columns.Add(resim); //Kayıt girişini gerçekleştiriyoruz. dataGridView1.Rows[0].Cells[0].Value = urun1; dataGridView1.Rows[0].Cells[1].Value = urun2; dataGridView1.Rows[0].Cells[2].Value = urun3; dataGridView1.Rows[0].Cells[3].Value = urun4; dataGridView1.Rows[0].Cells[4].Value = urun5; dataGridView1.Rows[0].Cells[5].Value = Image.FromFile(@"C:\Users\Pronet Yazılım\Desktop\logo.png"); } } }
Bu sana yardımcı olur.