如何将标签的文本添加到代码dom?
我有一个表单,其中有各种标签和一个按钮。在按钮单击事件上,编写了一段代码,该代码生成一个 cs 文件,我希望在其中显示标签的文本。
我正在尝试获取借助代码 dom 中的以下函数来获取值,但我无法提取标签的值,即我只是获取 label1.text、label2.text 等。相反,我想要标签中的值,并且组合框..
任何人都可以帮忙..
start.Statements.Add(new CodeVariableReferenceExpression("Info.Valid("\"combobox1.SelectedValue.ToString()\"", "\"label1.Text\"" , "\"label2.Text\"", "\"label3.Text\"", "\"numericupdown.Value.ToString()\"")");
这里的 start 是所有代码的 CodeMemberMethod要添加语句,Info 是另一个类,Valid 是我需要将所有这些值作为参数传递给的方法。
I have a form in which there are various labels and a button..on the button click event there is a code written which generates a cs file in which i want the text of the label to be displayed..
I am trying to get the values with the help of the following function in the code dom but m not able to extract the values of the label i.e. i am just getting label1.text, label2.text, etc. instead i want the values that are there in the labels and the combobox..
can anyone please help..
start.Statements.Add(new CodeVariableReferenceExpression("Info.Valid("\"combobox1.SelectedValue.ToString()\"", "\"label1.Text\"", "\"label2.Text\"", "\"label3.Text\"", "\"numericupdown.Value.ToString()\"")");
here start is the CodeMemberMethod to which all the statements are to be added, Info is another class and Valid is a method to which i need to pass all these values as arguments..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没错,您的代码不应提取任何值,因为您指定了文本常量。您可以使用 string.Format 方法来准备文本数据。尝试如下所示:
有关更多详细信息,请查看此
Thats right, your code shouldnt extract any values because you specifies text constants. You may use string.Format method to prepare text data. Try something like below:
For more details check out this