Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataGrid Display

DataGrid Display

Scheduled Pinned Locked Moved C#
csharpcsshelpquestion
18 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K kabutar

    hi again, one more doubt on this issue.... i want another form(form2) with text boxes to accept all the details and when i click on an update button on tis form the details should be shown on the data grid that is present on the form1.... ie i should have two forms:first form with data grid and form2 with text boxes for name ,roll number and classes ... what is the logic ie how can i make theses two forms communicate.... thanks again guys

    C#

    A Offline
    A Offline
    Abhijit Jana
    wrote on last edited by
    #9

    Hi, your question is not clear to me :confused::confused: where is ur update button? :doh: you want to update in Datagrid itself ? or update on a text box and after click on Update button update will reflect on DataGrid. :) ;) Can u kindly explain !!!! :cool:

    Happy Programming ----- Abhijit

    K 1 Reply Last reply
    0
    • A Abhijit Jana

      Hi, your question is not clear to me :confused::confused: where is ur update button? :doh: you want to update in Datagrid itself ? or update on a text box and after click on Update button update will reflect on DataGrid. :) ;) Can u kindly explain !!!! :cool:

      Happy Programming ----- Abhijit

      K Offline
      K Offline
      kabutar
      wrote on last edited by
      #10

      sure Abhijit i will explain: i have two windows form form1 and form2 in form one i have a datagrid and a "show button" when i click on the show button the second from ie form2 will pop up.... in this form2 i have text boxes and a "update button"....and when i enter the details on the text box and click on the update button in form2 all the details will get updated on to the datagrid in form1 do i need to use delegates for this purpose..... how cn do this.... Thanking you

      C#

      A 1 Reply Last reply
      0
      • K kabutar

        sure Abhijit i will explain: i have two windows form form1 and form2 in form one i have a datagrid and a "show button" when i click on the show button the second from ie form2 will pop up.... in this form2 i have text boxes and a "update button"....and when i enter the details on the text box and click on the update button in form2 all the details will get updated on to the datagrid in form1 do i need to use delegates for this purpose..... how cn do this.... Thanking you

        C#

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #11

        Thanks for Explining, I am asuming your database has Roll, Name , Address , Marks fields And Create a Load_Grid() Function on form_load() Load_Grid() { Load data to grid(); } Now see, in your datagrid there may be multiple records ? is it ? Now read the key value from that row, and pass the value in the next form. Supoose u select row 2 and roll=5, pass this to form 2, u can easily access the controls of other form just creating the object and access. Now in Form2, There is Three Text box, Roll : txtroll Name: txtName Address : txtAddress Now, SQLCommand cmd=new sqlcommand("select * from student where roll='_RollVal',conn) // _RollVal is passed value SqlDataReader dr=new Sqldatareader(); dr= cmm.executenonquery(); now u can get the value txtRoll.Text=dr[0].text txtName.Text=dr[0].text Now change the vale in text box, and on click on UpdateButton .... Update database [ Just use Update Command to Update] and back to the Form1..... , and all refresh data will come to you grid, cause , load_grid() will call on Form Load.:cool::cool: Hope You like This..... And for any query ask me ;) Good luck :)

        Happy Programming ----------------- Abhijit Jana Noida, India

        K 1 Reply Last reply
        0
        • A Abhijit Jana

          Thanks for Explining, I am asuming your database has Roll, Name , Address , Marks fields And Create a Load_Grid() Function on form_load() Load_Grid() { Load data to grid(); } Now see, in your datagrid there may be multiple records ? is it ? Now read the key value from that row, and pass the value in the next form. Supoose u select row 2 and roll=5, pass this to form 2, u can easily access the controls of other form just creating the object and access. Now in Form2, There is Three Text box, Roll : txtroll Name: txtName Address : txtAddress Now, SQLCommand cmd=new sqlcommand("select * from student where roll='_RollVal',conn) // _RollVal is passed value SqlDataReader dr=new Sqldatareader(); dr= cmm.executenonquery(); now u can get the value txtRoll.Text=dr[0].text txtName.Text=dr[0].text Now change the vale in text box, and on click on UpdateButton .... Update database [ Just use Update Command to Update] and back to the Form1..... , and all refresh data will come to you grid, cause , load_grid() will call on Form Load.:cool::cool: Hope You like This..... And for any query ask me ;) Good luck :)

          Happy Programming ----------------- Abhijit Jana Noida, India

          K Offline
          K Offline
          kabutar
          wrote on last edited by
          #12

          Awesome Thankyou :) :) :) But Abhijit i am not using the database

          C#

          A 1 Reply Last reply
          0
          • K kabutar

            Awesome Thankyou :) :) :) But Abhijit i am not using the database

            C#

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #13

            But, unless you use a database u can't store data permanently. At least you have to use a XML or CSV file do store records.;)

            Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

            K 1 Reply Last reply
            0
            • A Abhijit Jana

              But, unless you use a database u can't store data permanently. At least you have to use a XML or CSV file do store records.;)

              Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

              K Offline
              K Offline
              kabutar
              wrote on last edited by
              #14

              i dont want to store anything abhi i am trying to enter some detailes in one form and it shpould be shown in datagrid in another form.....if i donot stop the running and keep on updating i the datagrid will also get upgraded.... i almost did it using delegates can u plz check the codes and tell me because i got the code from somewhere else code form1:: public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void UpdateGridView(string name, string roll, string Class) { string[] data = new string[] { name,roll,Class }; dataGridView1.Rows.Add(data); } private void button1_Click(object sender, EventArgs e) { Form2 obj = new Form2(); obj.StudentDetails = new namedelegate(this.UpdateGridView); obj.ShowDialog(); obj.Close(); } } } code for form2:: public delegate void namedelegate(string name,string roll,string Class) ; public partial class Form2 : Form { public namedelegate StudentDetails; //creating an object of the delegate public Form2() { InitializeComponent(); } private void btnUpdate_Click(object sender, EventArgs e) { StudentDetails( txtName.Text, txtRoll.Text, txtClass.Text); } private void txtName_TextChanged(object sender, EventArgs e) { } } } Can you tell me how does the program flow work thanking you

              C#

              A 1 Reply Last reply
              0
              • K kabutar

                i dont want to store anything abhi i am trying to enter some detailes in one form and it shpould be shown in datagrid in another form.....if i donot stop the running and keep on updating i the datagrid will also get upgraded.... i almost did it using delegates can u plz check the codes and tell me because i got the code from somewhere else code form1:: public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void UpdateGridView(string name, string roll, string Class) { string[] data = new string[] { name,roll,Class }; dataGridView1.Rows.Add(data); } private void button1_Click(object sender, EventArgs e) { Form2 obj = new Form2(); obj.StudentDetails = new namedelegate(this.UpdateGridView); obj.ShowDialog(); obj.Close(); } } } code for form2:: public delegate void namedelegate(string name,string roll,string Class) ; public partial class Form2 : Form { public namedelegate StudentDetails; //creating an object of the delegate public Form2() { InitializeComponent(); } private void btnUpdate_Click(object sender, EventArgs e) { StudentDetails( txtName.Text, txtRoll.Text, txtClass.Text); } private void txtName_TextChanged(object sender, EventArgs e) { } } } Can you tell me how does the program flow work thanking you

                C#

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #15

                Why u make that simple thing as complex, if you dont want to use database just use XML 1 Abhijit Microsoft Use XMLReader and Write Object to Read and Write. It's Very Simple, :laugh: U can Create and Delete The XML File RunTime Also... So, No Overhead !!! Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                K 1 Reply Last reply
                0
                • A Abhijit Jana

                  Why u make that simple thing as complex, if you dont want to use database just use XML 1 Abhijit Microsoft Use XMLReader and Write Object to Read and Write. It's Very Simple, :laugh: U can Create and Delete The XML File RunTime Also... So, No Overhead !!! Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                  K Offline
                  K Offline
                  kabutar
                  wrote on last edited by
                  #16

                  ThankYou Abhijit :) :) :)

                  C#

                  A 1 Reply Last reply
                  0
                  • K kabutar

                    ThankYou Abhijit :) :) :)

                    C#

                    A Offline
                    A Offline
                    Abhijit Jana
                    wrote on last edited by
                    #17

                    just try it and let me know when done :-D:-D:-D

                    Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                    K 1 Reply Last reply
                    0
                    • A Abhijit Jana

                      just try it and let me know when done :-D:-D:-D

                      Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                      K Offline
                      K Offline
                      kabutar
                      wrote on last edited by
                      #18

                      Sure Will do so ......thanks again :) :)

                      C#

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups