TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vishnu V
NA
120
4.1k
combo box to datagrid view..didn't get items in grid view
Jul 11 2017 8:51 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Practice1
{
public partial class Form4 : Form
{
DataTable resultDT = new DataTable();
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
Emp objEmp = new Emp();
DataTable dttt = objEmp.getItem();
cbItems.DataSource = dttt;
cbItems.ValueMember = "ItemId";
cbItems.DisplayMember = "ItemName";
}
public DataTable getResult()
{
resultDT.Columns.Add("ItemId");
resultDT.Columns.Add("ItemName");
resultDT.Columns.Add("Quantity");
resultDT.Columns.Add("rate");
resultDT.Columns.Add("total cost");
resultDT.Columns.Add("MRP");
resultDT.Columns.Add("tax");
resultDT.Columns.Add("per unit cost");
resultDT.Columns.Add("Net amount");
DataRow rowDR = resultDT.NewRow();
rowDR["ItemId"] = cbItems.SelectedValue;
rowDR["ItemName"] = cbItems.Text;
rowDR["Quantity"] = txtQuantity.Text;
rowDR["rate"] = txtRate.Text;
rowDR["total cost"] = Convert.ToInt32(txtQuantity.Text) * Convert.ToInt32(txtRate.Text);
double cost = Convert.ToInt32(txtQuantity.Text) * Convert.ToInt32(txtRate.Text);
double tax = (cost * Convert.ToInt32(txttax.Text) / 100);
double totaltax = cost + tax;
double totaltaxx = totaltax / Convert.ToInt32(txtQuantity.Text);
rowDR["per unit cost"] = totaltaxx;
rowDR["Net amount"] = Convert.ToInt32(txtQuantity.Text) * totaltaxx;
rowDR["MRP"] = txtMRP.Text;
rowDR["tax"] = txttax.Text;
resultDT.Rows.Add(rowDR);
return resultDT;
}
private void button1_Click(object sender, EventArgs e)
DataTable resultDT = getResult();
dataGridView1.DataSource = resultDT;
}
}
}
Attachment:
vishnu23.rar
Reply
Answers (
3
)
how to Calculate Online Test Result & Marks using c# Code
Career in Database