Tampilkan postingan dengan label inputbox. Tampilkan semua postingan
Tampilkan postingan dengan label inputbox. Tampilkan semua postingan

Minggu, 13 Maret 2016

C# - How To Get Selected DataGridView Row Values Into InpuBoxes In C#

get selected datagridview row data

C# - How To Display Data From Selected DataGridView Row into InputBox Using C#

                                                                                                                                                     

In This C# Code We Will See How To Get A DataGridView Row Values Into  InpuBoxes
In C# Programming Language.




Source Code:

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;
using Microsoft.VisualBasic;

namespace WindowsFormsApplication1
{
    public partial class Csharp_Show_DatagridView_Row_Data_In_InputBox : Form
    {
        public Csharp_Show_DatagridView_Row_Data_In_InputBox()
        {
            InitializeComponent();
        }

        DataTable table = new DataTable();

        private void Csharp_Show_DatagridView_Row_Data_In_InputBox_Load(object sender, EventArgs e)
        {
            // populate DatagridView with some data using datatable
            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("First Name", typeof(String));
            table.Columns.Add("Last Name", typeof(String));
            table.Columns.Add("Age", typeof(int));

            table.Rows.Add(1, "AAA", "BBB", 32);
            table.Rows.Add(2, "CCC", "DDD", 23);
            table.Rows.Add(3, "EEE", "FFF", 16);
            table.Rows.Add(4, "GGG", "HHH", 45);
            table.Rows.Add(5, "III", "JJJ", 53);
            table.Rows.Add(6, "KKK", "LLL", 62);

            dataGridView1.DataSource = table;

        }

        // dataGridView Cell Click
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // get selected row index
            int selectedRowIndex = e.RowIndex;

            DataGridViewRow row = new DataGridViewRow();

            row = dataGridView1.Rows[selectedRowIndex];

            // get data from the selected row
            int id = int.Parse(row.Cells[0].Value.ToString());
            //string id2 = row.Cells[0].Value.ToString();
            string fn = row.Cells[1].Value.ToString();
            string ln = row.Cells[2].Value.ToString();
            int age = int.Parse(row.Cells[3].Value.ToString());

            // show the selected row data on inputboxes
            Interaction.InputBox("The Id", "Row Data", id.ToString(), -1, -1);
            Interaction.InputBox("The First Name", "Row Data", fn, -1, -1);
            Interaction.InputBox("The Last Name", "Row Data", ln, -1, -1);
            Interaction.InputBox("The Age", "Row Data", age.ToString(), -1, -1);
        }
    }
}

/////////////////////////// OUTPUT:

Baca selengkapnya

C# - How To Add A Row To DataGridView Using InputBox In C#

datagridview add row using inputbox

C# - How To Insert Data Using InputBoxes Into DataGridView In C#

                                                                                                                                                     

In This C# Code We Will See How To Add A Row To DataGridView From InputBoxes 
In C# Programming Language.



Source Code:

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;
using Microsoft.VisualBasic;

namespace WindowsFormsApplication1
{
public partial class Add_Row_DatagridView_Using_InputBox_Csharp : Form
{
public Add_Row_DatagridView_Using_InputBox_Csharp()
{
InitializeComponent();
}
DataTable table = new DataTable();
private void Add_Row_DatagridView_Using_InputBox_Csharp_Load(object sender, EventArgs e)
{
table.Columns.Add("Id", typeof(int));
table.Columns.Add("First Name", typeof(String));
table.Columns.Add("Last Name", typeof(String));
table.Columns.Add("Age", typeof(int));

dataGridView1.DataSource = table;
}

// Button Add Row
private void BtnAddRow_Click(object sender, EventArgs e)
{
// get data from inputboxes
int id = int.Parse(Interaction.InputBox("Enter The Id", "Data", "", -1, -1));
string fn = Interaction.InputBox("Enter The First Name", "Data", "", -1, -1);
string ln = Interaction.InputBox("Enter The Last Name", "Data", "", -1, -1);
int age = int.Parse(Interaction.InputBox("Enter The Age", "Data", "", -1, -1));

table.Rows.Add(id, fn, ln, age);

dataGridView1.DataSource = table;
}
}
}



/////////////////////////////////OUTPUT:
c# add row to datagridview from inputbox
c# add row to datagridview

ALSO SEE : 
Remove A Row From DataGridView
Get Selected Row Values From DataGridView Into TextBox
Update A DataGridView Row With TextBox
Add Delete And Update DataGridView Row Using TextBoxes
Baca selengkapnya

C# - Add And Use InputBox In C#

add inputbox to c#

C# - How To Add And Use InputBox In C#

                                                                                                                                                     

In This C# Code We Will See How To Add InputBox And Use It In C# Programming Language





Source Code:

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;

using Microsoft.VisualBasic;


namespace WindowsFormsApplication1
{
public partial class Add_InputBox_To_Csharp : Form
{
public Add_InputBox_To_Csharp()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Interaction.InputBox("Message", "Title", "Default Value", -1, -1);
}
}
}


/////////////////////////////////OUTPUT:


add inputbox to c#
Add And Use InputBox In C#
ALSO SEE : 
Remove A Row From DataGridView
Get Selected Row Values From DataGridView Into TextBox
Update A DataGridView Row With TextBox
Add Delete And Update DataGridView Row Using TextBoxes
Baca selengkapnya