Sending data between 2 forms

Sending data between 2 forms

By : Korhan Karagozoglu
Date : November 22 2020, 04:01 AM
I wish did fix the issue. Well, since you are calling Form1 frm1 = new Form1(); - what else did you expect than opens up another instance of form1 ? - Why should new Form1() not produce another instance?
You will need to get the reference of the already created Form1.
code :
var frm1 = Application.OpenForms[0];
//frm1.Show(this); <- don't need to call Show since its already open
private void btnExecute_Click(object sender, EventArgs e)
    var frm1 = Application.OpenForms[0] as Form1; //find `Form1` like you want, I only take [0]

    //always create a new instance of SqlConnection here and dispose it with the using Keyword
    //don't use a private field to try to keep the Connection, let the internal Connection pool handle that case
    using (var con = new SqlConnection(@"Data Source=srvr;Initial Catalog =db; User ID =user; Password =pass"))

            //clean up, Command/Reader with using keyword
            using (var cmd = con.CreateCommand())
                cmd.CommandText = txtQuery.Text;
                using (SqlDataReader reader = cmd.ExecuteReader())
                    //read data
        catch (Exception ex)
            MessageBox.Show("Error executing command.\n" + ex.Message);

    //should activate the `Form1` AFTER the job is done, you can consider if you only want to activate it if the previous Code didn't fail
if (reader.HasRows)
    DataTable schema = reader.GetSchemaTable();
    int field_num = 0;
    foreach (DataRow schema_row in schema.Rows)
        int col_num = frm1.dataGridView1.Columns.Add(
            "col" + field_num.ToString(),

        frm1.dataGridView1.Columns[col_num].AutoSizeMode = 

    object[] values = new object[reader.FieldCount];

    while (reader.Read())
frm1.dataGridView1.AutoGenerateColumns = true; //say to automatically create columns, based on the result inside the datatable
var dataTable = new DataTable();
dataTable.Load(dataReader); //load the SqlDataReader into the DataTable
frm1.dataGridView1.DataSource = dataTable; //set the dataGridView's DataSource to the dataTable

Share : facebook icon twitter icon
Sending listBox data between Forms

Sending listBox data between Forms

By : K. Szot
Date : March 29 2020, 07:55 AM
will help you Hello im new to to the C# stuff I'm just learning. , Pass the values in the constructor:
code :
string _listValue;
public Racun(string listValue)
    _listValue = listValue;
private void button1_Click(object sender, EventArgs e)
    var form1 = new Rancun(_listBox);
get { return listBox1.SelectedValue.ToString(); }
Sending custom data with forms

Sending custom data with forms

By : takara
Date : March 29 2020, 07:55 AM
hop of those help? You can turn radio buttons into buttons, this is a quick idea
code :
<div class="buttons">
    <input type="radio" name="rb" id="rb1" value="1"/><label for="rb1">One</label>
    <input type="radio" name="rb" id="rb2" value="2" /><label for="rb2">Two</label>
    <input type="radio" name="rb" id="rb3"  value="3"/><label for="rb3">Three</label>
.buttons input {

.buttons input + label{
    cursor: pointer;
    width: 2em;
    padding: .3em;
    border: 1px solid black;
    color: #000;
    box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1);

.buttons input:checked + label{
    background-color: red;

.buttons input + label:hover{
  color: #222;
  box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.3);
Gravity Forms sending entry data combined from multiple forms to third-party after submitting a specific form

Gravity Forms sending entry data combined from multiple forms to third-party after submitting a specific form

By : Tal Goldberg
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Because you are specifying the form ID in the add_action itself, you are only running your function when the Gravity Form, with an ID of 2, is submitted. If you want it to run for multiple submissions, but then limit it to specific form IDs, then something more like this:
code :
   add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
   function post_to_third_party( $entry, $form ) {

    if( $form->id == 2 || $form->id == somenumber ) {
        $post_url = 'http://thirdparty.com';
        $body = array(
            'first_name' => rgar( $entry, '1.3' ), 
            'last_name' => rgar( $entry, '1.6' ), 
            'message' => rgar( $entry, '3' ),

        $request = new WP_Http();
        $response = $request->post( $post_url, array( 'body' => $body ) );
Sending Data Between Two Forms C#

Sending Data Between Two Forms C#

By : Thohidul Islam
Date : March 29 2020, 07:55 AM
I hope this helps . As response on your question/bug, like Mong Zhu pointed out:
Your bug is found here:
code :
class 2

namespace Internship_Test
    public partial class Form2 : Form
        string[] user = new string[5];
        public Form2()

        public string b2;

        private Form1 _form1;   // you need to create a field for the form1

        public Form2(Form1 form1)
            b2 = obj.b;
            _form1 = form1; 


        public string username;

        private void button1_Click(object sender, EventArgs e)
            username = textBox2.Text;
            //Form1 obj = new Form1(this);
            // instead of creating a new form, just pop it up:
Sending data between forms without using .Show()

Sending data between forms without using .Show()

By : Luke A. Lowe
Date : March 29 2020, 07:55 AM
it helps some times One way is by creating a public event and registering for that event from the other form.
Related Posts Related Posts :
  • C# Linq Find duplicates with multiple group by
  • How to call control on a Panel that is inside usercontrol
  • c# ReadAsJsonAsync in framework 4.5
  • Inner join two table variables and return an output cursor from an anonymous plsql block in a c# application
  • Notify consumers when all tasks have completed without blocking the thread
  • Replace "\\" with "\" in a path
  • CSS Not formatting inside repeater
  • CheckedListBox filter with a TextBox
  • How to not evaluate the third part of a ternary operator unless necessary
  • How to avoid going into cache block in c# and return to loop iteration?
  • How do I add just one element to an array when I call a method c#
  • Image.RotateFlip doesn't seem to rotate the Bitmap
  • swagger add document and operation for a generic controller
  • Avoid a random selection of the same point to imitate "human-like" behavior
  • Howto use PostgreSQL table names without double quotes in C# and Npgsql
  • .NET Core Entity Framework InvalidOperationException
  • Database Context save if valid
  • How do I flatten an array of arrays?
  • Serialize Property as Xml Attribute in new Element
  • How to make a flash-animation with a row of pictureboxes?
  • Add ClientId to the "Authorized API Clients"
  • How do you get POSTed value from dynamically populated dropdownlist without the use of UpdatePanel?
  • C# Inconsistent accessibility: return type is less accessible than method
  • MVC Razor how to get option value from form and set viewmodel property to selected value
  • Automapper error after updating a record with POCO classes, Unity and EF6
  • Xamarin Forms Change NavBar background image on Specific pages
  • No service while customize a new User Context Identity
  • How to recognize element in which item in the gridview
  • Loading DataGridView only once based on listbox item selected
  • WCF Service not hitting from postman over https
  • Export telerik RadGrid to PDF
  • Why won't C# decimal ToString request culture AND currency?
  • Using constant string in all include pages
  • Write Roslyn analyzer by Rider
  • What is the difference between a dSYM folder and an mSYM folder?
  • replace inheritance with generic extension method
  • C# XAML binding
  • Span<T> and streams in .NET framework
  • Using phyton.exe in .net c# controller:
  • How to get distinct values from set of rows matching condition
  • MySqlParameter type conflict when using Entity Framework with Pomelo
  • Why there is black color shed on the upper side and left side on textbox border in ASP.Net
  • Autofac resolving named service incorrectly
  • Cumulative sum of array items
  • Bot connector returns Forbidden (403) with Microsoft.Bot.Connector.ErrorResponseException
  • What is the right way to show only group by column in datatable
  • C# Trying to get a list of questions from one class into my Main() class loop
  • In database AutoIncrease column. What if value reached maximum value
  • How to access controls of dynamically added user controls in a panel in C#?
  • Dynamic DataTable Group by and Aggregate functions
  • Binding selected ListBox Image somewhere else in MainWindow
  • Apply Ninject to work with "child viewmodels" in my C# WPF application
  • Create System.Net.WebProxy from string including credentials
  • error in implementing Ignite.net with persistence
  • WPF Button click not properly comparing variable to array value
  • Create custom iterable Dictionary with one generic type
  • How do I use ExecuteScalar with a stored Procedure?
  • HttpPostedFileBase always returns null when posting it with Model but working perfact without model
  • WIndows 10 MIDL.exe
  • Different versions of ODAC causing error in C# application (local Vs Server)
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org