hi every body ,
I want to write a program with vb.net about calculating the GPA
in my program I'll ask the user to Enter the number of courses then I'll
Generate ComboBox(s) by the number of courses
...
So How can I do the dynamic Generate of the combobox ...:icon_idea:

if u can give me a simple code plz !!
thanx in advance.
best Regards.
:)

Recommended Answers

All 3 Replies

hi every body ,
I want to write a program with vb.net about calculating the GPA
in my program I'll ask the user to Enter the number of courses then I'll
Generate ComboBox(s) by the number of courses
...
So How can I do the dynamic Generate of the combobox ...:icon_idea:

if u can give me a simple code plz !!
thanx in advance.
best Regards.
:)

Hi...
i faced a similar problem but
I used a flowPanel control.
Though directly not what i intended to use,
yet the program works, and the items are easily arranged.

Attaching my sample project.
Hope this helps you...

And if by any means you figure out to draw runtime controls directly on the form, i would appreciate that.

Drop a button and a panel on a form and try this code:

Public Class frmDynamic

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim lastComboBox As ComboBox = Nothing
		Dim i1 As Integer
		For i1 = 0 To 10
			lastComboBox = GetComboBoxUnder(lastComboBox)
			Panel1.Controls.Add(lastComboBox)
		Next
	End Sub

	Private Function GetComboBoxUnder(ByRef cb As ComboBox) As ComboBox
		Dim result As New ComboBox()
		If Not (cb Is Nothing) Then
			result.Top = cb.Top + cb.Height
			result.Left = cb.Left
		End If

		Return result
	End Function
End Class

thanks a lot
Arunabh Nag & sknake.

but dear sknake , could u plz explain the following code i didn't understand it :

#
If Not (cb Is Nothing) Then

result.Top = cb.Top + cb.Height

result.Left = cb.Left

End If

And How can I add items for each Combobox..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.