Skip to main content
Improved code formatting.
Source Link
Pang
  • 10.2k
  • 146
  • 87
  • 126

I looped over the properties of the EventArgs like this and pulled out its X and Y values.

private void navBarControl1_Click(object sender, EventArgs e) { int _x = 0; int _y = 0;

 Type t = e.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(t.GetProperties()); foreach (PropertyInfo prop in props) { if (prop.Name == "X") { object propValue = prop.GetValue(e, null); _x = Convert.ToInt32(propValue); } if (prop.Name == "Y") { object propValue = prop.GetValue(e, null); _y = Convert.ToInt32(propValue); } } 
private void navBarControl1_Click(object sender, EventArgs e) { int _x = 0; int _y = 0; Type t = e.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(t.GetProperties()); foreach (PropertyInfo prop in props) { if (prop.Name == "X") { object propValue = prop.GetValue(e, null); _x = Convert.ToInt32(propValue); } if (prop.Name == "Y") { object propValue = prop.GetValue(e, null); _y = Convert.ToInt32(propValue); } } 

I looped the properties of the EventArgs like this and pulled out its X and Y values.

private void navBarControl1_Click(object sender, EventArgs e) { int _x = 0; int _y = 0;

 Type t = e.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(t.GetProperties()); foreach (PropertyInfo prop in props) { if (prop.Name == "X") { object propValue = prop.GetValue(e, null); _x = Convert.ToInt32(propValue); } if (prop.Name == "Y") { object propValue = prop.GetValue(e, null); _y = Convert.ToInt32(propValue); } } 

I looped over the properties of the EventArgs like this and pulled out its X and Y values.

private void navBarControl1_Click(object sender, EventArgs e) { int _x = 0; int _y = 0; Type t = e.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(t.GetProperties()); foreach (PropertyInfo prop in props) { if (prop.Name == "X") { object propValue = prop.GetValue(e, null); _x = Convert.ToInt32(propValue); } if (prop.Name == "Y") { object propValue = prop.GetValue(e, null); _y = Convert.ToInt32(propValue); } } 
Source Link

I looped the properties of the EventArgs like this and pulled out its X and Y values.

private void navBarControl1_Click(object sender, EventArgs e) { int _x = 0; int _y = 0;

 Type t = e.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(t.GetProperties()); foreach (PropertyInfo prop in props) { if (prop.Name == "X") { object propValue = prop.GetValue(e, null); _x = Convert.ToInt32(propValue); } if (prop.Name == "Y") { object propValue = prop.GetValue(e, null); _y = Convert.ToInt32(propValue); } }