如何将天数添加到ActiveReports 6和C#上的TextBox
我有ActiveReport 6和C#,然后尝试将6天添加到TextBox1值/文本中 这是我尝试的方法,
string text1 = this.textbox1.Text;
我也尝试
string text1 = this.textbox1.Text.ToString();
或字符串text1 = this.textbox1.value
将字符串转换为时间
DateTime date1 = Datime.Parse(text1);
,我继续遇到错误“ Invocation” 如何将文本框数据字符串转换为DateTime?还是如何解决调用错误的目标?
i have activereport 6 and C# and i try to add 6 days to textbox1 value/text
this is what i try
string text1 = this.textbox1.Text;
i also try
string text1 = this.textbox1.Text.ToString();
or string text1 = this.textbox1.Value
convert string to time
DateTime date1 = Datime.Parse(text1);
i keep getting error "target of invocation"
how do i convert textbox data string to datetime? or how do i fix that target of invocation error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该是从文本框中获取文本值的正确方法,因为它已经是字符串。
从那里,您应该能够使用标准.NET方法将其转换为日期时间。您做的方式对我来说是正确的,基于 Microsoft's文档。但是,假设您的字符串的格式是dateTime.parse()方法默认理解的格式之一。他们的文档中的示例:
如果您的字符串与 dateTime.parse默认理解您可能需要使用自定义格式,我相信这可能是您收到的错误的来源。
That should be the correct way to get the text value from the textbox, as it is already a string.
From there you should be able to use the standard .NET methods to convert it to a DateTime. The way you did it looks correct to me based on Microsoft's docs. However, that's assuming the format your string is in is one of the formats the DateTime.Parse() method understands by default. Example from their docs:
If your string is in a different format from one of the handful that DateTime.Parse understands by default you may need to use a custom format, and I believe that could be the source of the error you're receiving.