By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

Cursor Disappears in DataGrid cell, vb.net 1.1

P: 1
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
Oct 6 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.