网格充满了文本框,c#,XAML(Grid full of textboxes, c#, XAML)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
网格充满了文本框,c#,XAML(Grid full of textboxes, c#, XAML)

首先我不得不说,当我的英语不是很好的时候,所以我很抱歉我的错误和语法。 我有很多文本框创建的简单时间表,它们在组网格中。 我有一个buttom,用于在文本框中添加一些文本。 用户将在texbox中添加一些文本,点击按钮(创建)并创建完整的时间表,他需要什么。 而且有一个问题。 我可以在方法e.PageState["something"] = gui_Something.Text;手动保存所有输入,如下所示: e.PageState["something"] = gui_Something.Text; ,但我有3个网格,其中有40个文本框......我需要一些方法将它们全部保存在一个方法中,或类似的东西。 它看起来像田野,但事实并非如此。 在现场我可以做类似的事情:

int[] field = new int[5]; int some = 0; for (int i = 0; i < field.Length; i++) { field[i] = some; e.PageState["Something" + i] = gui_poznamky.Text; }

但我的网格充满了文本框不是字段xD

有人能帮助我吗? 我是初学者,我从很短的时间开始编程,所以有时我需要一些帮助。 感谢所有答案,我很抱歉我的英语(:

for start i have to say, when i'm not so good in english, so i'm sorry for my faults and grammar. I have easy timetable created from lot of text boxes, that are in group grid. I have one buttom, that serving to add some text into textboxes. User will add some text into texbox, will click on button (Create) and will create the complete timetable, what he need. And there is a problem. I could save all of input manually in method SaveState like this: e.PageState["something"] = gui_Something.Text; , but i have 3 grids where is 40 textboxes... I need some way to save it all in one method, or something like that. It looks like field, but it is not. In field i can do something like:

int[] field = new int[5]; int some = 0; for (int i = 0; i < field.Length; i++) { field[i] = some; e.PageState["Something" + i] = gui_poznamky.Text; }

but my grid full of textboxes is not field xD

Can someone help me please? I'm beginner, i started with programing short time ago, so sometimes i need some help. Thank for all answers and again i'm sorry for my english (:

最满意答案

你可以尝试这样的东西迭代网格中的所有控件,然后做一些奇特的工作来找到每个文本框的数据应保存到哪里...

foreach (Control childCtrl in MainGrid.Children) { if (childCtrl is TextBox) { TextBox Txtbox = (TextBox)childCtrl; Console.WriteLine("Found Textbox: " + Txtbox.Name); } }

You could try something like this to iterate though all the controls in the grid, and then do some fancy work to find where each textboxs' data should be saved to...

foreach (Control childCtrl in MainGrid.Children) { if (childCtrl is TextBox) { TextBox Txtbox = (TextBox)childCtrl; Console.WriteLine("Found Textbox: " + Txtbox.Name); } }

更多推荐

文本框,field,Text,需要,电脑培训,计算机培训,IT培训"/> <meta name="description

本文发布于:2023-04-13 12:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/efb664a01b6f6ebc9abe8853bb47392b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   文本框   XAML   textboxes   full

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!