This is a migrated thread and some comments may be shown as answers.

Find and select the name of dynamically added tab

3 Answers 101 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Min
Top achievements
Rank 1
Min asked on 11 May 2009, 04:57 AM
Hi,

I am just trying to migrate from Visual Basic 6.0 to .net. And really new to telerik rad controls for winform. In my form I have added a tab control which will dynamically created tabitems and 3 different contols within each tab. Could someone please help me to find the name of tabitems and control added dynamically. Each time when loop starts functioning I want to check where the new tab item is already added by loop or not.  

 

Private Sub ShowData()  

 

Dim i As Integer  

 

Dim tmpWord As String  

 

Dim tmprelateto As String  

 

Dim itab As Integer  

 

Dim newtab As String

ds =
New DataSet()

 

myAdapter.Fill(ds,

"Dictionary")

 

 

mytable = ds.Tables(

"Dictionary")

 

 

tmprelateto =

""

 

 

 

tmpWord = ""

i = 0

 

Do
myrow = mytable.Rows.Item(rownumber)

 

tmpWord = Trim(myrow.Item(

"Word").ToString)

 

 

tmprelateto = Trim(myrow.Item(

"relateto").ToString)

 

 


If
tmprelateto = "" Then

    i = i + 1 

    If i = 2 Then

 

         Exit Do

 

    End If

    RichTextBox1.Text = Trim(myrow.Item(

"DefNep").ToString)

 

    RichTextBox2.Text = Trim(myrow.Item(

"DefEng").ToString)
    rownumber = rownumber + 1

Else
     newtab = Trim(myrow.Item("pref").ToString)

 

     RadTabStrip1.Items.Add(

New TabItem(newtab))

     Dim list As New ListBox
     Dim rtfbox As New RichTextBox

     Dim rtfbox2 As New RichTextBox

     For Each ti As TabItem In RadTabStrip1.Items

        ti.ContentPanel.Controls.Add(list)

        ti.ContentPanel.Controls.Add(rtfbox)

        ti.ContentPanel.Controls.Add(rtfbox2)

 

 

 

 

    With list  

            .Location =

 

New Point(5, 3)

 

            .Width = 132
            .BorderStyle = BorderStyle.None

            .Height = 117

             

 

If Trim(myrow.Item("Word").ToString) = "" Then

 

                 

 

.Items.Add(Trim(myrow.Item("relateto").ToString))

 

             

 

Else  

 

 

 

                 .Items.Add(Trim(myrow.Item(

"Word").ToString))

 

             

 

End If

 

 

    

 

End With

 

 

 

 

 

    With rtfbox

 

            .Location =

 

New Point(141, 3)

 

            .Width = 133

            .Height = 117

            .BorderStyle = BorderStyle.None

            .Text = Trim(myrow.Item(

 

"DefNep").ToString)  

 

 

 

    End With

 

 

 

 

 

    With rtfbox2

             .Location =

 

New Point(278, 3)

 

             .Width = 132

             .Height = 117

             .BorderStyle = BorderStyle.None

             .Text = Trim(myrow.Item(

 

"DefEng").ToString)

 

     

 

End With

 

 

 

Next  

 

 

 

rownumber = rownumber + 1 

End If  

 

 

Loop  

 

 

End Sub

Database Used above program looks like:
Word        relateto        pref        DefNep                                                DefNep
-------        ---------        ------       ---------                                                 ---------
A               Null             Null         (ए) अंग्रेजी वर्णमालाको पहिलो अक्षर         the first letter of the English alphabet
Null            A                adj.         एउटा, कोही, एक कुनै व्यक्ति                     one, any, some
Null            A                prep.      जब संज्ञामा उपसर्गको जस्तो यो              (when used as a prefix before nouns) 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 14 May 2009, 08:22 AM
Hello Min,

Thank you for your question. Well I am not sure what you mean by loop -- in WinForms you do not have direct access to the application loop and you use events which are a nice abstraction, well the right abstraction when it comes to event driven progamming.

You can find general information about RadTabStrip control in our online help. Here is the help topic about adding/removing tabs programmatically. You can add controls dynamically using the code in this forum post.

Do not hesitate to write us back if you have further questions. I hope your trial period is going overall fine.

All the best,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Min
Top achievements
Rank 1
answered on 14 May 2009, 09:42 AM
Dear Admin,

Thank you very much for giving interest in my question.  Actually I am trying to develop the English-Nepali Dictionary based on SQL Server database. As in the sample data that I have provided. I want to dispaly word and its definition in a rich text box and Its related words like Adverb, Noun, Preposition should be display on the tab control. These tab controls should have listbox, and two richtext box. These tab controls should be created if we only have related word of one major word. And If a word have more that 2 nouns for example then they should be listed on a list box of the tab control. 
My problem her is I have been able to create tab controls dynamically but, I haven't been able to find which tab control has been created and which is not. If we have more than one same related words then they should be dispalyed on the list box of a tab control already created; instead of creating new with the same name. 

Loop here is used to find the words and its related words.

Regards,
Min Raj Gurung
0
Nick
Telerik team
answered on 14 May 2009, 01:55 PM
Hello Min,

Thank you for writing us back. You may first declare variables for your tabitems and initialize the items in some way:

   TabItem verb; 
  TabItem adjective; 
 
 
  private void Form1_Load(object sender, EventArgs e) 
  { 
            verb = new TabItem(); 
            verb.Name = "verb"
            verb.Text = "Verb";            
  } 

When your user hits the search button for example you may add the tabitems to the tab strip in the order you want:

private void radButton1_Click(object sender, EventArgs e) 
    this.radTabStrip1.Items.Add(verb); 

You may use the item name to check whether this is a verb tab, noun tab, etc if you iterate over the items collection.

You may have some boolean variables about whether tabs are shown or not. Please refer to the online help about further details such as adding tabs, removing tabs, making a tab selected.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Min
Top achievements
Rank 1
Answers by
Nick
Telerik team
Min
Top achievements
Rank 1
Share this question
or