困扰着标签页!! [英] Troubled with tabpages!!

查看:70
本文介绍了困扰着标签页!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了一个Windows应用程序,当用户单击按钮时,它会使用输入框询问选项卡名称.根据用户输入,将创建一个新表单,并将tabpage.text属性设置为用户输入.

我面临2个问题:confused :: confused:

1.我在按钮单击事件中添加了控件,以将其添加到选项卡页面.现在我该如何保存内容,例如,我已经添加了代码以创建一个文本框以添加到标签页中.我如何保存文本框的文本.我使用了添加处理程序并提供了一个子地址.但是无法访问动态创建的文本框.

2.我要保存用户创建的选项卡,以便下次运行该应用程序时出现.创建最后一次创建的选项卡. (我尝试过my.settings.save)

请任何人在这里帮助我.我在Google上搜索了很多,但没有得到具体的答案.请提前谢谢!!

Hi All,

I have created a windows application in which-when the user clicks a button it asks for the tab name using an inputbox. based on the user input, a new form gets created with the tabpage.text property set to the user input.

I am facing 2 problems:confused::confused:

1. I added controls in the button click event to add it to the tabpage. Now How can i save the contents, for ex..i''ve added code to create a text box to add in the tabpage. How cn i save the textbox''s text. I used add handler and gave the address of a sub.but am not able to access the dynamically created textbox.

2.I want to save the tabpages that the user created so that when the next time, the application is run..the tabpages that wer created the last time shud be present. (I tried my.settings.save)

Please anyone help me out here. I googled a lot but am not getting a specific answer.Thanx in advance!!

推荐答案

第一个问题:

您为处理程序创建的子包含2个参数(通常称为发送者"和"e")

发件人参数(类型对象)是动态创建的文本框,因此,如果将其转换为文本框,则可以从其中获取文本.

关于第二个问题:

这将需要更多的工作.
您必须为此使用序列化.
Google有点用,因为在这里的简短帖子中解释非常复杂.
一些使您入门的链接:
(k奇怪,他们在工作中表现完美)

无论如何,请尝试此链接(谷歌搜索),它在vb.net中有许多序列化链接

^ ]
For your first question:

The sub you created for the handler contains 2 parameters (typically called ''sender'' and ''e'')

The sender param (type object) is your dynamically created textbox so if you cast that one to a textbox you will be able to get the text out of it.

For your second question:

This will require some more work.
You''ll have to use serialization for this.
Google it a bit because it''s quite complicated to explain in a short post here.
Some links to get you started:
(k that''s just weird they worked perfectly at work)

anyway try this link (google search) it has many links to serialization in vb.net

http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=form+%2B+serialize#sclient=psy&hl=en&q=vb.net+%2B+serialize&aq=f&aqi=g4g-o1&aql=&oq=&gs_rfai=&pbx=1&fp=fa151da40c6c8a2[^]


汤姆,

感谢您为我的第一个问题提供的解决方案.效果很好!

这就是我所做的(对于所有困扰着同一问题的人)

Hi Tom,

Thanks for the solution for my first problem. It works perfectly!!

This is what i did (for all those who are haunted with this same problem)

'button click to create dynamically a textbox

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim t As New TextBox
        t.Location = New System.Drawing.Point(84, 56)
        AddHandler t.LostFocus, AddressOf copy
        Me.Controls.Add(t)
End Sub

'And here is the lostfocus event for the textbox that was created

Protected Sub copy(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim t As TextBox = sender
        MsgBox(t.Text)
End Sub



现在我要解决第二个问题!谢谢...顺便指出我的正确方向.



Now I gotta work on the second problem!! Thank you ...by the way for pointing me in the right direction.


这是您一直在寻找的宝石.限制此类的使用.我可以用来从树状视图的顶级节点保存整个树节点链.

here is the gem you have been looking for. To scope the use of this class. I can be used to save a whole chain of treenodes from the top level node of a treview.

Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary

<Serializable()> Public Class SaveLoad

    Sub WriteFile(ByVal FileName As String, ByVal FileObject As Object)

        Dim ms As MemoryStream = New MemoryStream
        Dim bf As BinaryFormatter = New BinaryFormatter

        bf.Serialize(ms, FileObject)

        File.WriteAllBytes(FileName, ms.ToArray)

    End Sub

    Function ReadFile(ByVal FilePath As String) As Object

        Dim ms As MemoryStream = New MemoryStream(File.ReadAllBytes(FilePath))
        Dim bf As BinaryFormatter = New BinaryFormatter
        Dim FileObject As Object = DirectCast(bf.Deserialize(ms), Object)

        Return FileObject

    End Function

End Class


这篇关于困扰着标签页!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆