我正在使用Kinect并测量关节速度。我有一种测量速度的方法,我想在kinect应用程序的GUI中的文本框中编写它。
我如何在我的功能中做到这一点?如何将TextBox作为参数传递给函数?
public void Velocity(double[] doub)
{
double speed;
// MY CODE for speed aquisiction
speed = deltax/deltat //the deltas are calculated above, no need to show it here
Boxname.Text = speed.ToString(); //i want this to work inside the method
}
答案 0 :(得分:2)
传递Textbox
不是一个很好的选择。在创建函数时,函数执行其工作并返回计算值会更有意义。因此,只要我需要获取值,我就可以通过简单地调用函数来实现。
通过这种方式,我可以按照我想要的任何目的使用该值,例如设置文本框的文本。
如果你做这样的事情会很棒
public double Velocity(double[] doub)
{
double speed;
// MY CODE for speed aquisiction
speed = deltax/deltat //the deltas are calculated above, no need to show it here
return speed;
}
// update the text of textbox by calling the function wherever required.
Boxname.Text = Velocity().ToString();