我有一个应用程序,可以让你画一个活动图,我需要从这个图生成一个算法。
我的问题是如何在拖放后获得文本框的值?
下面是我在按钮中编写的代码:
private void generat_algo(object sender, ExecutedRoutedEventArgs e)
{
{
IEnumerable<DesignerItem> designerItems = this.Children.OfType<DesignerItem>();
IEnumerable<Connection> connections = this.Children.OfType<Connection>();发布于 2012-11-13 22:37:56
如果您只有一个textbox,则只需按名称访问该textbox:
textbox1.Text或者,如果您需要支持多个文本框,那么您可以简单地在拖放完成时获取文本。只需处理Drop事件并检查它是否是被移动的textbox:
private void Canvas_Drop(object sender, DragEventArgs e)
{
bool itemIsTextbox = (e.Data.GetDataPresent(typeof(TextBox)) == true);
//get the textbox then get hte text out of it
if (itemIsTextbox)
string text = (TextBox)e.Data.GetData(typeof(TextBox)).Text;
}https://stackoverflow.com/questions/13357920
复制相似问题