Hi everyone, i am new to C# .net. Can some one help me out with the below prblm: I have a tabcontrol in my windows form application, where the tab pages are generated dynamically. the content to be displayed on each tab wud be fetched from my database. i need some kind of control(which can display the fetched data) that i can add on each tab page (which wud be same for all tabs) such that i can associate some kind of event say click on that added control. can anyone tell me how to do this programmatically & write the click event for all the controls added.
views:
1828answers:
3I'm not sure I completely understand your problem but my initial thoughts are that you could dynamically create a datagrid or something similar for each tab that you are dynmically creating. You could then bind the datasource for the grid and then add the grid as a control to your tabpage.
Something like...
DataGridView gv = new DataGridView();
gv.DataSource = //whatever your source is
this.tabPage1.Controls.Add(gv);
You would then have all the events associated with the grid to work with.
Please refer the below link! You will get more detail in this regard.
I'm thinking data binding is going to be your best bet for displaying this information. You can create a list of objects and use a DataTemplate to format the data. You can apply the DataTemplate to a quite a few objects. I generally use the ItemsControl and ListBox
http://msdn.microsoft.com/en-us/library/ms750612.aspx
good luck