i am having a problem regarding the disappearance of the cursor in the DataGrid cell after i change the width of the column on runtime.here is a function which is being called in the Textchanged handler of the embedded Textbox of DataGrid Cell.
Private Sub UpgradeGridColumns()
Dim colText As String
Dim currColumn As DataColumn
Dim currColStyle As DataGridTextBoxColumn
Dim ColumnStyle As DataGridTextBoxColumn
Dim ds As DataSet
Dim Graphics As Graphics = lookupMapGrid.CreateGraphics()
Dim DataTable As DataTable
ds = mLookupMapOutputRule.Mappings.DataSet
DataTable = ds.Tables(0)
currColumn = DataTable.Columns.Item(lookupMapGrid.CurrentCell.C olumnNumber)
For Each ColumnStyle In mTableStyle.GridColumnStyles
If (Not IsDBNull(currColumn.ColumnName)) AndAlso ColumnStyle.MappingName.Equals(currColumn.ColumnNa me) Then
colText = ColumnStyle.TextBox.Text.ToString()
If colText Is Nothing Then Exit Sub
If (Graphics.MeasureString(colText, lookupMapGrid.Font).Width > ColumnStyle.Width) Then
' since the column width change causes the whole text to be selected and the
'insertion point(.TextBox.SelectionStart) sets to 0 so we want to save the insertion
'point
Dim insertionPoint As Integer = ColumnStyle.TextBox.SelectionStart
If insertionPoint < 0 Then Exit Sub
ColumnStyle.Width = CType(Graphics.MeasureString(colText, lookupMapGrid.Font).Width, Integer) + 5
' after width change, the whole text gets selected and we dont want that
ColumnStyle.TextBox.SelectionStart = insertionPoint
ColumnStyle.TextBox.SelectionLength = 0
ColumnStyle.TextBox.Focus()
ColumnStyle.TextBox.Cursor.Show()
ColumnStyle.TextBox.ScrollToCaret()
End If
End If
Next
End Sub
does anyone have any idea whats the problem or any workaround? thanks