Click here to Skip to main content
15,897,718 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionLocalization with VB .net and Access Database Pin
rhaseena6-Mar-07 11:10
rhaseena6-Mar-07 11:10 
QuestionIt looks right? Pin
Anybloodyid6-Mar-07 10:37
Anybloodyid6-Mar-07 10:37 
AnswerRe: It looks right? Pin
Christian Graus6-Mar-07 10:46
protectorChristian Graus6-Mar-07 10:46 
AnswerRe: It looks right? Pin
JUNEYT6-Mar-07 10:50
JUNEYT6-Mar-07 10:50 
GeneralRe: It looks right? Pin
Anybloodyid6-Mar-07 11:06
Anybloodyid6-Mar-07 11:06 
AnswerRe: It looks right? Pin
Taylor Kobani6-Mar-07 22:46
Taylor Kobani6-Mar-07 22:46 
QuestionLet user add new items to a databound combobox Pin
NDD576-Mar-07 9:55
NDD576-Mar-07 9:55 
AnswerRe: Let user add new items to a databound combobox Pin
Scott Page7-Mar-07 12:23
professionalScott Page7-Mar-07 12:23 
I would suggest not binding to the combobox using the DataSource property as a solution. I'll give you a rough example, though I haven't tested it, I know it is possible.

Assuming the following:
A ComboBox named 'cboItems'
A Button named 'btnUpdate'
A TextBox named 'tbItemName'
A Typed-DataSet named 'dsData' of type ExampleDataSet
A Typed-DataTable in 'dsData' named 'ExampleItems' of type ExampleDataTable
A DataColumn in 'ExampleItems' named 'ItemName'

<code>
Public Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'We will implement custom sorting, so disable the ComboBox automatic sorting
Me.cboItems.Sorted = False
Me.RefreshItems
End Sub

Private Sub RefreshItems
'Create a temp StringCollection to sort our data
Dim SortedItems As New Collections.StringCollection
For Each IRow as ExampleDataSet.ExampleRow In Me.dsData.ExampleItems
SortedItems.Add(IRow.ItemName)
Next
'Sort the list before adding it to the ComboBox
SortedItems.Sort
Me.cboItems.Clear
Me.cboItems.BeginUpdate 'Begin updating the combobox, recommended but not required all of the time
'Add the "Add New Item" first to ensure it is the first item
Me.cboItems.Items.Add("Add New Item")
For Each Name As String In SortedItems
Me.cboItems.Items.Add(Name)
Next
Me.cboItems.EndUpdate 'Finished updating the combobox
SortedItems = Nothing
'At this point, our ComboBox has at least one item "Add New Item" so we can safetly
'set the ComboBox.SelectedItem to 0
Me.cboItems.SelectedIndex = 0
'Alternative
'Me.cboItems.SelectedIndex = Me.cboItems.Items.IndexOf("Add New Item")
End Sub

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click
Me.dsData.ExampleItems.AddExampleItemRow(Me.tbItemName.Text)
'After adding an item to the datasource, refresh the list to reflect the changes
'This can be done after deleting a row or updating it as well
Me.RefreshItems
End Sub

</code>

The previous example will work. However, I would suggest possibly using a button on the main form that opens a child form when clicked. The child form would have all of the controls needed to add the item. When the child form closed you could then add an item. This would allow you to bind directly to the combobox and not worry about all of the previous code.

Hope this helps,
If you have any other questions feel free to ask

Scott Page


"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
( President Ronald Reagan)
GeneralRe: Let user add new items to a databound combobox Pin
NDD579-Mar-07 7:36
NDD579-Mar-07 7:36 
Questiona Simple Clock Alarm Pin
HoseinQuest6-Mar-07 9:43
HoseinQuest6-Mar-07 9:43 
AnswerRe: a Simple Clock Alarm Pin
JUNEYT6-Mar-07 10:41
JUNEYT6-Mar-07 10:41 
QuestionCan't see ODBC datasource Pin
cstrader2326-Mar-07 8:07
cstrader2326-Mar-07 8:07 
QuestionChanging the time or date field of the timedate control panel using shell command Pin
JewelOfTheNile6-Mar-07 7:30
JewelOfTheNile6-Mar-07 7:30 
AnswerRe: Changing the time or date field of the timedate control panel using shell command Pin
GoodID6-Mar-07 21:19
GoodID6-Mar-07 21:19 
QuestionBar code scanner Pin
Brad Fackrell6-Mar-07 5:46
Brad Fackrell6-Mar-07 5:46 
AnswerRe: Bar code scanner Pin
kubben6-Mar-07 7:18
kubben6-Mar-07 7:18 
GeneralRe: Bar code scanner Pin
Brad Fackrell6-Mar-07 9:54
Brad Fackrell6-Mar-07 9:54 
QuestionProblem with thread Pin
Nilesh Hapse6-Mar-07 5:11
Nilesh Hapse6-Mar-07 5:11 
AnswerRe: Problem with thread Pin
Scott Page6-Mar-07 13:35
professionalScott Page6-Mar-07 13:35 
GeneralRe: Problem with thread Pin
Nilesh Hapse7-Mar-07 22:28
Nilesh Hapse7-Mar-07 22:28 
QuestionUsing Assembly with multiple versions Pin
nitin_ion6-Mar-07 4:53
nitin_ion6-Mar-07 4:53 
AnswerRe: Using Assembly with multiple versions Pin
Parwej Ahamad6-Mar-07 7:22
professionalParwej Ahamad6-Mar-07 7:22 
GeneralRe: Using Assembly with multiple versions Pin
nitin_ion6-Mar-07 16:27
nitin_ion6-Mar-07 16:27 
QuestionControling the Button in Window Form Pin
drexler_kk6-Mar-07 4:18
drexler_kk6-Mar-07 4:18 
AnswerRe: Controling the Button in Window Form Pin
JUNEYT6-Mar-07 5:22
JUNEYT6-Mar-07 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.