Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > List to Detail form
 

List to Detail form

I need a common database scenario. Display a list of records in one form (datagridview?). When the user double clicks one record, a different form is open with the details of the selected record

This must be possible in MSVS 2008 using .NET 3.5, but all my searching has not found any good examples

The list view would place all the records in a datatable, butonly limited details
The detail view would be all the details, but only for the one selected record

TIA
MPty
empytea  Thursday, September 10, 2009 2:56 PM
Hello,

Thanks for your post.

To edit records in the detailed Form, we can bind the controls on the detailed form to the same data source the DataGridView control is bound to. Here is an sample for your reference.

http://www.codeproject.com/KB/vb/DataGridViewEditForm.aspx

And more information about data binding
http://www.codeproject.com/KB/database/databinding_tutorial.aspx

If you have any additional question, welcome to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byempytea Monday, September 14, 2009 2:15 PM
  •  
Rong-Chun Zhang  Friday, September 11, 2009 3:55 AM
Hello,

Thanks for your post.

To edit records in the detailed Form, we can bind the controls on the detailed form to the same data source the DataGridView control is bound to. Here is an sample for your reference.

http://www.codeproject.com/KB/vb/DataGridViewEditForm.aspx

And more information about data binding
http://www.codeproject.com/KB/database/databinding_tutorial.aspx

If you have any additional question, welcome to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byempytea Monday, September 14, 2009 2:15 PM
  •  
Rong-Chun Zhang  Friday, September 11, 2009 3:55 AM
Hi,
I am binding student details in the first form datagridview.when i doubleclick the datagridview cell.i collect all the content releated to that cell.and pass that value to second form constructor ther i am get all the values and display it in the message box.in your case you bind it your own design.
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
	if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
	{
		StudentInfo info = new StudentInfo();
		info.StdNo =Convert.ToInt32
			(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString());
		info.Name = 
			dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[1].Value.ToString();              
		info.Lecture = 
			dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[2].Value.ToString();
		info.Year = Convert.ToInt32
			(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value.ToString());
		info.Exam1 = Convert.ToInt32
			(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[4].Value.ToString());
		Form2 frm = new Form2(info);
		frm.Show();
	}
}

}
public class StudentInfo
{
private int stdNo;

public int StdNo
{
	get { return stdNo; }
	set { stdNo = value; }
}
private string name;

public string Name
{
	get { return name; }
	set { name = value; }
}


private string surName;

public string SurName
{
	get { return surName; }
	set { surName = value; }
}
private string lecture;

public string Lecture
{
	get { return lecture; }
	set { lecture = value; }
}
private int year;

public int Year
{
	get { return year; }
	set { year = value; }
}
private int exam1;

public int Exam1
{
	get { return exam1; }
	set { exam1 = value; }
}

}
StudentInfo stuInfo;
public Form2(StudentInfo info)
{
	InitializeComponent();
  stuInfo=new StudentInfo();
	stuInfo=info;
}

private void Form2_Load(object sender, EventArgs e)
{
	MessageBox.Show(stuInfo.StdNo.ToString() + stuInfo.Name + stuInfo.Lecture + stuInfo.Year + stuInfo.Exam1);
}


Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
  • Proposed As Answer byGnanadurai Monday, September 14, 2009 5:03 AM
  •  
Gnanadurai  Friday, September 11, 2009 4:50 AM

You can use google to search for other answers

Custom Search

More Threads

• Application Exception?
• Binding Navigator Desapiring
• DataGridViewColumnHeaderCell
• SortCommand event handler does not fires for dynamically added columns in datagrid
• Howto store datasoure in Dataset for later use.
• DataGridView - skip columns with the tab key or arrow keys
• Change cell type in CellValueNeeded event
• Help with datasets
• How Do I Use or Setup a Multiple Table DataGrid Using VB 2008?
• from webservice to dataGridview