TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
haezeban
NA
6
0
Reflection how to get the contents of that object
Feb 12 2010 10:17 AM
Hi,
public partial class Form1 : Form
{
private Type type;
private Type typeItems;
private Type typeDataSource;
Public form1()
{
typeDataSource = typeof(PremieTabel);
typeItems = PremieTabel.Items.GetType();
codeTabel = "PremieTabel";
dataGridView2.DataSource = PremieTabel.Items;
lblTitel.Text = codeTabel;
......
}
public btn-clickevent(object sender, EventArgs e)
{
// Export data to csv file
FieldInfo[] fields = typeDataSource.GetFields();
PropertyInfo[] properties = typeDataSource.GetProperties();
}
Starting the program typeDataSource, typeItems are filled up with the Items of object PremieTabel. Also the datagrid is filled up correctly.
But we won't use reflection ( because I have the same code a lot but with the items of a different object).
In runtime I push button btn. I want to know which datasource is displayed on screen (in this case PremieTabel.Items) and get the contents
of it so I can export the contents to a csv. file.
I can check which type is in scope, but who can I get teh data of that object.
Thanks
Reply
Answers (
1
)
vs 2008 c# make button visible
how to read from a msword doc and put the content in a xml file?