The other day I wanted to add news tags feature to a program, and to make it easy I wanted the user to be able of adding and removing news tags by double clicking a Listbox of available tags and assigned tags.
If you need to move items between bound Listboxes you cannot just use the Listbox.Add or Listbox.Remove methods. Instead you should add and remove rows to the Tables which they’re bound to.
This is the code I used:
Private Sub AvailableTagListBox_DoubleClick(sender As System.Object, e As System.EventArgs) Handles AvailableTagListBox.DoubleClick
If Not IsNothing(AvailableTagListBox.SelectedItem) Then
'We are making a new row to be added to the table which then will appear in the listbox
Dim Customer_News_Tags_Row As DataRow = MyDataSet.Customer_News_Tags.NewRow
'Since I have a Parent and Child relation I'm taking the current parent ID
Dim NewsRow = DirectCast(Me.Customer_NewsBindingSource.Current, DataRowView)
Customer_News_Tags_Row("News_ID") = NewsRow("ID")
'Fill the listbox item display field which I have it bound to
Customer_News_Tags_Row("Tag") = AvailableTagListBox.Text
'Adding new item to the other listbox by adding new row to its table
'Delete the listbox item by deleting the row in its table
MyDataSet.News_Tags.Select("ID=" & AvailableTagListBox.SelectedValue)(0).Delete()
Private Sub AssignedTagListBox_DoubleClick(sender As System.Object, e As System.EventArgs) Handles AssignedTagListBox.DoubleClick
If Not IsNothing(AssignedTagListBox.SelectedItem) Then
Dim News_Tags_Row As DataRow = MyDataSet.News_Tags.NewRow
'I'm using a field called Tag
News_Tags_Row("Tag") = AssignedTagListBox.Text
'Here I'm matching with a field I have called Tag to delete from Assigned listbox items
MyDataSet.Customer_News_Tags.Select("Tag='" & AssignedTagListBox.SelectedValue & "'")(0).Delete()
Hope this helps, and if you need any clarifications let me know
Let’s say you have a project source hosted in your private Visual Studio Online (Team Foundation Service) account and you want to move it to another account. The easiest way I found is to connect to the new account from Visual Studio (File->Connect to Team Project) and add the items to the source control:
Assuming you already have the source on your computer, just select them to be added. Also It will ask you to map a new work space for this new source:
Hit finish and then you are ready to check in the files.
I’ve been using Visual Studio Online for few months now since it was in beta when it was called Team Foundation Service and I totally love it!
The service gives you the ability to collaborate for free for up to 5 members and then you need to license users. I used it to collaborate with a friend and it gave us great help and it was very easy to use. Even though it is great for collaboration but I think you can use it also on your own for good maintenance.
If you are trying to use GamerMaker Studio wih Visual Studio 2013 and getting the error Unable to validate WinJS API Reference even though you prepared the requirements you have to change the settings to point to Visual Studio 2013 directory and change the WinJS version to 2 like in the following screenshot:
Note that I have pointed the Windows SDk to 8.1 since I’ve got Windows 8.1.
I was working on a report which involved several tables and relationships between these tables.
I made sure that I’ve loaded and filled the table sources I tried launching my report but kept on getting the error “Unknown Database Connector Error”.
After a little bit of debugging what I suspected was true. You have to make sure that the tables or the tables’ links are executed in a correct order that doesn’t break the relations.
Basically it is best to load the father tables and then children tables.
To do that open the Database Expert which comes with Crystal Reports -> Links -> Order Links
It worked for me without checking the “Link ordering is enforced”.
Hope this helps
A bound DataGridView ComboBox Column doesn’t allow user input. You might come across a situation where you need to make it easier for the user to select an item from the ComboBox and at the same time allow them to just enter free text.
The trick is to make the ComboBox column without a DataSource and then you load the items by code. Also you have to handle a couple of stuff such as the EditingControlShowing event to convert the ComboBox style to be DropDown instead of DropDownList, and some other handling to commit the ComboBox change.
I will leave you with the code:
Private Sub MyForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Get ComboBox items
'Fill the ComboBox
Dim row As DataRow
For Each row In Me.MyDataSet.ComboBoxTable
'Generic list used as a trick to have the ComboBox Items added with Value
MyComboBox.Items.Add(New GenericListItem(Of String)(row.Item("ColName"), row.Item("ColValue")))
'Adding Grid handler to detect change in run time
AddHandler MyDataGridView.CurrentCellDirtyStateChanged, AddressOf MyDataGridView_CurrentCellDirtyStateChanged
'Change ComboBox style to DropDown
Private MyDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As MyDataGridViewEditingControlShowingEventArgs) Handles MyDataGridView.EditingControlShowing
If TypeOf e.Control Is ComboBox Then
Dim cb As ComboBox = TryCast(e.Control, ComboBox)
cb.DropDownStyle = ComboBoxStyle.DropDown
'When an item is selected from the ComboBox update the cell value
If MyDataGridView.Columns(MyDataGridView.CurrentCell.ColumnIndex).Name = "MyComboBox" Then
Dim selectedComboBox As ComboBox = DirectCast(e.Control, ComboBox)
RemoveHandler selectedComboBox.SelectionChangeCommitted, AddressOf selectedComboBox_SelectionChangeCommitted
AddHandler selectedComboBox.SelectionChangeCommitted, AddressOf selectedComboBox_SelectionChangeCommitted
Private Sub selectedComboBox_SelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs)
Dim selectedCombobox As ComboBox = DirectCast(sender, ComboBox)
If selectedCombobox.SelectedItem IsNot Nothing Then
'Use the List we created earlier so we could retrieve the Value instead of the diplayed text
Dim oItem As GenericListItem(Of String) = CType(selectedCombobox.SelectedItem, GenericListItem(Of String))
Me.MyDataGridView.Item("ColumnName", MyDataGridView.CurrentCell.RowIndex).Value = oItem.Value()
Catch ex As Exception
Private Sub MyDataGridView_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As EventArgs) Handles MyDataGridView.CurrentCellDirtyStateChanged
'Commit the change which was in run time so the Value changed event happens and then allow one check box
If MyDataGridView.IsCurrentCellDirty Then
Private Sub MyDataGridView_CellValidating(sender As Object, e As System.Windows.Forms.MyDataGridViewCellValidatingEventArgs) Handles MyDataGridView.CellValidating
'Allow user to enter new values for all MyDataGridViewComboBox controls in the MyDataGridView
If (TypeOf CType(sender, MyDataGridView).EditingControl Is MyDataGridViewComboBoxEditingControl) Then
Dim cmb As MyDataGridViewComboBoxEditingControl = CType(CType(sender, MyDataGridView).EditingControl, MyDataGridViewComboBoxEditingControl)
If Not cmb Is Nothing Then
Dim grid As MyDataGridView = cmb.EditingControlMyDataGridView
Dim value As Object = cmb.Text
'// Add value to list if not there
If cmb.Items.IndexOf(value) = -1 Then
'// Must add to both the current combobox as well as the template, to avoid duplicate entries...
Dim cmbCol As MyDataGridViewComboBoxColumn = CType(grid.Columns(grid.CurrentCell.ColumnIndex), MyDataGridViewComboBoxColumn)
If Not cmbCol Is Nothing Then
grid.CurrentCell.Value = value
''Following Works for a specific combobox ///////////
'If e.ColumnIndex = MyMyDataGridView.Columns("MyDataGridViewComboBoxColSize").Index Then 'CType(sender, MyDataGridView).CurrentCell.ColumnIndex
' 'Dim cmb As ComboBox = CType(e.Control, ComboBox)
' Dim cmb As MyDataGridViewComboBoxEditingControl = CType(CType(sender, MyDataGridView).EditingControl, MyDataGridViewComboBoxEditingControl)
' If Not cmb Is Nothing Then
' Dim grid As MyDataGridView = cmb.EditingControlMyDataGridView
' Dim value As Object = cmb.Text
' '// Add value to list if not there
' If cmb.Items.IndexOf(value) = -1 Then
' '// Must add to both the current combobox as well as the template, to avoid duplicate entries...
' Dim cmbCol As MyDataGridViewComboBoxColumn = CType(grid.Columns(grid.CurrentCell.ColumnIndex), MyDataGridViewComboBoxColumn)
' If Not cmbCol Is Nothing Then
' End If
' grid.CurrentCell.Value = value
' End If
' End If
Public Class GenericListItem(Of T)
Private mText As String
Private mValue As T
Public Sub New(ByVal pText As String, ByVal pValue As T)
mText = pText
mValue = pValue
Public ReadOnly Property Text() As String
Public ReadOnly Property Value() As T
Public Overrides Function ToString() As String
I hope this helps, and if you have any question let me know.
So you have decided you want to get into SharePoint, but you find out that you need to have a pretty strong machine to run it. Actually the latest SharePoint 2010 needs 6 GB of RAM as a starting point to run well and a 64 bit Windows 2008 operating system.
You could actually learn without installing a thing! Yes. Microsoft offers a great service called MSDN Virtual Labs. Using these Virtual Labs you can test and try almost every Microsoft technology and product. And of course SharePoint Virtual Labs is one of them. In the Lab courses you get to learn and have hands-on experience. They even include software which you would need like SharePoint Designer. Really helpful.
So go on and have fun