Affichage des articles dont le libellé est textBox. Afficher tous les articles
Affichage des articles dont le libellé est textBox. Afficher tous les articles

VB.Net Clear All TextBoxes

How To Clear All TextFields Using Visual Basic.Net

Remove Text From All TextBoxes In VB.Net



In this VB.Net Tutorial we will see How To Remove Text From All TextBoxes Inside A Form On Button Click Event In Visual Basic.Net Programming Language And Visual Studio IDE .




Project Source Code:

Public Class ClearAllTextBoxes

    Private Sub ButtonClear_Click(sender As Object, e As EventArgs) Handles ButtonClear.Click

        For Each c As Control In Controls

            If c.GetType() = GetType(TextBox) Then

                c.Text = ""

            End If

        Next

    End Sub
End Class
                                       

////// OUTPUT : 

set all textboxes text to empty using vbnet



VB.Net TextBox Allow Only Alphabet

How To Make A TextBox Accept Only Alphabet Values Using Visual Basic.Net

vb.net textbox allow only alphabet


In This VB.Net Tutorial we will See How To Make A TextBox That Allow Only Letter Characters + White Space On KeyPress Event using Visual Basic.Net Programming Language And Visual Studio IDE .


Project Source Code:


Public Class TextBox_Only_Alphabet


    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress

        If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsLetter(e.KeyChar) AndAlso Not Char.IsWhiteSpace(e.KeyChar) Then

            e.Handled = True

        End If

    End Sub
End Class




OUTPUT:



textbox allow only characters using vbnet



VB.Net TextBox Allow Only Numbers

How To Make A TextBox Accept Only Numeric Values Using Visual Basic.Net

textbox accept only digits characters in vb.net


In This VB.Net Tutorial we will See How To Make A TextBox That Allow Only Number Characters On KeyPress Event using Visual Basic.Net Programming Language And Visual Studio IDE .


Project Source Code:


Public Class TextBox_Only_Number


    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress

        If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) Then

            e.Handled = True

        End If

    End Sub
End Class




OUTPUT:



textbox allow only number using vbnet



VB.NET - How To Add Delete And Update DataGridView Row Using TextBoxes In VBNET

VB.NET - How To Add Delete And Update Row From DataGridView Using TextBoxes In VB.NET 

                                                                                                                         

In This VB.NET Tutorial We Will See How To Add A Row To DataGridView From TextBox, Update A Selected Row Using TextBox, And Delete The Selected Row In VB.NET Programming Language.


Project Source Code:

Imports System.Data.DataTable

Public Class Add_Update_Delete_DataGridView_Row

 ' Create a new datatable
    Dim table As New DataTable("Table")

    Dim index As Integer

    Private Sub Add_Update_Delete_DataGridView_Row_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    ' Add columns to your datatable, 
    ' with the name of the columns and their type 
        table.Columns.Add("Id", Type.GetType("System.Int32"))
        table.Columns.Add("First Name", Type.GetType("System.String"))
        table.Columns.Add("Last Name", Type.GetType("System.String"))
        table.Columns.Add("Age", Type.GetType("System.Int32"))

         ' Add rows to the datatable with some data
        table.Rows.Add(1, "XXXX", "YYYYY", 21)
        table.Rows.Add(2, "SSDD", "hGSQ", 33)
        table.Rows.Add(3, "fgfgd", "jgfdd", 53)
        table.Rows.Add(4, "cvfghyghj", "sdrgtyh", 19)
        table.Rows.Add(5, "hghfd", "ghjgdf", 36)
        table.Rows.Add(6, "cvvdfgh", "juyrfdvc", 63)
        table.Rows.Add(7, "aefht", "cvfhytrff", 21)
        table.Rows.Add(8, "wghyuj", "mihgdwrh", 33)
        table.Rows.Add(9, "qsztii", "bvdhjh", 53)
        table.Rows.Add(10, "rytyufd", "esdfzr", 19)

   'set data from datatable to datagridview
        DataGridView1.DataSource = table

    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click

        table.Rows.Add(TextBoxID.Text, TextBoxFN.Text, TextBoxLN.Text, TextBoxAGE.Text)

        DataGridView1.DataSource = table

    End Sub

    Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick

        ' get the index of the selected datagridview row
        index = e.RowIndex
        Dim selectedRow As DataGridViewRow

   ' show data from the selected row to textboxes
        selectedRow = DataGridView1.Rows(index)
        TextBoxID.Text = selectedRow.Cells(0).Value.ToString()
        TextBoxFN.Text = selectedRow.Cells(1).Value.ToString()
        TextBoxLN.Text = selectedRow.Cells(2).Value.ToString()
        TextBoxAGE.Text = selectedRow.Cells(3).Value.ToString()

    End Sub

    Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
         ' the new row
        Dim newDataRow As DataGridViewRow

        newDataRow = DataGridView1.Rows(index)

   ' get data from textboxes to the row
        newDataRow.Cells(0).Value = TextBoxID.Text
        newDataRow.Cells(1).Value = TextBoxFN.Text
        newDataRow.Cells(2).Value = TextBoxLN.Text
        newDataRow.Cells(3).Value = TextBoxAGE.Text

    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click

        DataGridView1.Rows.RemoveAt(index)

    End Sub
End Class

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




vb.net add a row to datagridview using textboxes
vb.net add a row to datagridview
vb.net update a datagridview row using textboxes
vb.net update a datagridview row

vb.net delete a datagridview selected row
vb.net delete a datagridview row





C# - How To Update A DataGridView Row With TextBox In C#

C# - How To Update A DataGridView Row With TextBoxes In C#

__________________________________________________________________________

In This C# Code We Will See How To  Update A DataGridView Row Using TextBoxes In CSharp Programming Language .



Project 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;

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

        DataTable table = new DataTable();
        int indexRow;

        private void Update_DataGridView_Using_TextBoxes_Load(object sender, EventArgs e)
        {
   // set datatable columns values
   table.Columns.Add("Id", typeof(int));// data type int
   table.Columns.Add("First Name", typeof(string));// datatype string
   table.Columns.Add("Last Name", typeof(string));// datatype string
   table.Columns.Add("Age", typeof(int));// data type int

            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);

            dataGridView1.DataSource = table;

        }

        // Get Selected Row Values From DataGridView Into TextBox
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            indexRow = e.RowIndex; // get the selected Row Index
            DataGridViewRow row = dataGridView1.Rows[indexRow];

            textBoxID.Text = row.Cells[0].Value.ToString();
            textBoxFN.Text = row.Cells[1].Value.ToString();
            textBoxLN.Text = row.Cells[2].Value.ToString();
            textBoxAGE.Text = row.Cells[3].Value.ToString();
        }

        //update datagridview row data 
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DataGridViewRow newDataRow = dataGridView1.Rows[indexRow];
            newDataRow.Cells[0].Value = textBoxID.Text;
            newDataRow.Cells[1].Value = textBoxFN.Text;
            newDataRow.Cells[2].Value = textBoxLN.Text;
            newDataRow.Cells[3].Value = textBoxAGE.Text;
        }
    }
}
/////////////////////////// OUTPUT: 
C# Update DataGridView Selected Row Using TextBoxes
DatagridView Row Uodated

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



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

C# - How To Displaying Data From Selected Rows In DataGridView into TextBox Using C#

                                                                                                                                                     

In This C# Code We Will See How To Get A DataGridView Row Values Into  TextBoxes 
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;

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

        DataTable table = new DataTable();

        private void DataGridView_Row_Data_To_TextBoxes_Load(object sender, EventArgs e)
        {
            // set datatable columns values
            table.Columns.Add("Id", typeof(int));// data type int
            table.Columns.Add("First Name", typeof(string));// data type string
            table.Columns.Add("Last Name", typeof(string));// data type int
            table.Columns.Add("Age", typeof(int));// data type string

            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);

            dataGridView1.DataSource = table;

        }

        //Get Selected Row Values From DataGridView Into TextBox
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.RowIndex;// get the Row Index
            DataGridViewRow selectedRow = dataGridView1.Rows[index];
            textBoxID.Text = selectedRow.Cells[0].Value.ToString();
            textBoxFN.Text = selectedRow.Cells[1].Value.ToString();
            textBoxLN.Text = selectedRow.Cells[2].Value.ToString();
            textBoxAGE.Text = selectedRow.Cells[3].Value.ToString();

        }
    }
}




C# - How To Add A Row To DataGridView From TextBox In C#

C# - How To Insert Data From Textboxes To DataGridView In C#

                                                                                                                                                     

In This C# Code We Will See How To Add A Row To DataGridView From TextBoxes 
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;

namespace WindowsFormsApplication1
{
    public partial class Add_Row_To_DataGridView_Using_TextBoxes : Form
    {
        public Add_Row_To_DataGridView_Using_TextBoxes()
        {
            InitializeComponent();
        }
        DataTable table = new DataTable();

        private void Add_Row_To_DataGridView_Using_TextBoxes_Load(object sender, EventArgs e)
        {
   // set datatable columns values
   table.Columns.Add("Id", typeof(int));// data type int
   table.Columns.Add("First Name", typeof(string));// datatype string
   table.Columns.Add("Last Name", typeof(string));// datatype string
   table.Columns.Add("Age", typeof(int));// data type int

            dataGridView1.DataSource = table;
        }

         //add a row to datatable
        private void btnAdd_Click(object sender, EventArgs e)
        {
           
            table.Rows.Add(textBoxID.Text, textBoxFN.Text, textBoxLN.Text, textBoxAGE.Text);
            dataGridView1.DataSource = table;

        }
    }
}

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

C# Add Row To DataGridView From TextBoxes
Row Added
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