Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataRepeater forgets entered value when the DataRepeaterItem loses focus while out of view

$
0
0

I have the following problem.

A simple databound DataRepeater (Microsoft Visual Basic PowerPack 10) with one TextBox and some rows of data, just enough that the first row is out of view when you focus the last row.

1. Enter a value in the TextBox of the first row.

2. Scroll to the last row so that the first row gets out of view (without changing the focus!)

3. Focus the textbox of the last row

4. Go back to the first row

5. The entered value is gone!

Here is a sample code for easy reproduction of the issue. You have to perform the steps described above manually.

Public Class Form1

   Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
      ' Set Form size
      Me.Size = New System.Drawing.Size(320, 240)

      ' Some dummy data
      Dim DummyData As New DataTable("Data")
      DummyData.Columns.Add("ID", GetType(Integer)).AutoIncrement = True
      DummyData.Columns.Add("Text", GetType(String))
      For i As Integer = 1 To 10
         DummyData.Rows.Add(DBNull.Value, DBNull.Value)
      Next

      ' TextBox
      Dim Edit As New TextBox()
      Edit.Multiline = True
      Edit.Dock = DockStyle.Fill
      Edit.DataBindings.Add("Text", DummyData, "Text", False, DataSourceUpdateMode.OnPropertyChanged)

      ' New DataRepeater
      Dim DR As New Microsoft.VisualBasic.PowerPacks.DataRepeater()
      DR.Dock = DockStyle.Fill
      ' No new items
      DR.AllowUserToAddItems = False
      ' No deletion of items
      DR.AllowUserToDeleteItems = False
      ' No item headers
      DR.ItemHeaderVisible = False
      ' Prepare DataRepeater ItemTemplate (add TextBox)
      DR.BeginResetItemTemplate()
      DR.ItemTemplate.Controls.Add(Edit)
      DR.EndResetItemTemplate()

      ' Add DataRepeater to Form
      Me.Controls.Add(DR)

      ' Set DataSource
      DR.DataSource = DummyData

   End Sub
End Class

Can anyone give me a hint to solve this problem?

Best regards

R.Low



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>