Author Topic: BindingNavigator does not show correct data information  (Read 454 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16791
  • Superior Stupidity at its best
BindingNavigator does not show correct data information
« on: March 27, 2020, 09:51:55 AM »
Ok, this one is mixed code because one project is in VB.Net, and the other is in C#. A binding navigator is desired to navigate through a table of records that list various items in the drawing. These items have been enumerated and populated into a list of objects.

The object
Code - C#: [Select]
  1. public class insert
  2. {
  3.     public struct IntData
  4.     {
  5.         private string _id;
  6.         private string _intname;
  7.         private int _streetcount;
  8.         public int StreetCount { get { return _streetcount; } set { _streetcount = value; }}
  9.         public string IntersectionName { get { return _intname; } set { _intname = value; }}
  10.         public string ID { get { return _id; } set { _id = value; }}
  11.         public IntData(string id = "")
  12.         {
  13.             _id = "";
  14.             _intname = "";
  15.             _streetcount = 0;
  16.         }
  17.     }
  18. }

Code - Visual Basic: [Select]
  1. 'The list of objects
  2. Private ids As List(Of insert.IntData) = insert.CycleIntvol(, True)
  3.  
  4. Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  5.      For Each inters As insert.IntData In ids
  6.          'Create new row using predefined schema and fill it with data
  7.         Dim dr As DataRow = DataSet1.Tables("Intersections").NewRow()
  8.          dr.Item(0) = inters.ID
  9.          dr.Item(1) = inters.IntersectionName
  10.          dr.Item(2) = inters.StreetCount
  11.          DataSet1.Tables("Intersections").Rows.Add(dr)
  12.      Next
  13.      BindingNavigator1.DataBindings.Add(New Binding("Text", Me.DataSet1, "Intersections.ID", True))
  14.      BindingNavigator1.DataBindings.Add(New Binding("Tag", Me.DataSet1, "Intersections.StreetCount", True))
  15. End Sub

The BindingSource, Table, and DataSet are all design-time objects created by the IDE and when stepping through the code, the dataset shows the table and the correct number of rows and columns.

I'm sure its a rookie mistake but I'll be darned if I can see it.

Also, I have tried BindingLists, this was my last resort to try and get something working.

I know I'm gonna feel like an idiot when someone points out the simplicity of the resolution.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Sheriholty

  • Mosquito
  • Posts: 1
Re: BindingNavigator does not show correct data information
« Reply #1 on: May 28, 2020, 03:06:06 AM »
I do not know how many updates have been made so I can not help recommending them.