DataGrid Display
-
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#
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
-
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
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#
-
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#
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
-
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
-
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"
-
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"
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#
-
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#
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"
-
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"
-
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"
-
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"