protected override void OnLoad(EventArgs e) { //First we load the list of Orders to datarepeater1 Program.CompanyContext _context = new Program.CompanyContext(); List <list_inside_list.Program.Order> listOrders = _context.Order.ToList(); program_OrderBindingSource1.DataSource = listOrders; //I don´t know why, but we need to load the list of items as well, although we never use the listItems variable List <list_inside_list.Program.Item> listItems = _context.Item.ToList(); /* * 1. We will loop through all the datarepater1 items (which is fed with listOrders) * 2. We assign currItem as datarepeater1.CurrentItem in order to "select" the current item at index j, * although we will never user currItem * 3. We tell the program that of the current datarepeater item we want use the current Order object * 4. We go through each of the currentOrder.items and print the itemName * */ DataRepeaterItem currItem = new DataRepeaterItem(); for (int j = 0; j < this.dataRepeater1.ItemCount; j++) { this.dataRepeater1.CurrentItemIndex = j; currItem = dataRepeater1.CurrentItem; var currentOrder = (list_inside_list.Program.Order)program_OrderBindingSource1.Current; foreach (var item in currentOrder.items) { dataRepeater1.CurrentItem.Controls["richTextBox1"].Text = dataRepeater1.CurrentItem.Controls["richTextBox1"].Text + item.itemName + "\n"; } } }
// ... some other code private void dataRepeater1_CurrentItemIndexChanged(object sender, EventArgs e) { if (DataRepeater1_PreviousItem != null) { DataRepeater1_PreviousItem.BackColor = Color.White; } dataRepeater1.CurrentItem.BackColor = Color.Red; DataRepeater1_PreviousItem = dataRepeater1.CurrentItem; }
private void txtSplit_textChanged(object sender, EventArgs e) { try { UltraNumericEditor txt = sender as UltraNumericEditor; DataRepeaterItem item = (txt.Parent) as DataRepeaterItem; item.Controls["ultraLabel3"].Text = txt.Value.ToString(); } catch (Exception e1) { } }
public void curveDataRepeater_ItemTemplate_Paint(object sender, PaintEventArgs e) { DataRepeaterItem item = sender as DataRepeaterItem; Control checkBox = item.Controls["curveSelectedCheckBox"]; Control nameLabel = item.Controls["curveNameLabel"]; int y = (checkBox.Top + checkBox.Bottom) / 2; e.Graphics.DrawLine( item.Tag as Pen, checkBox.Location.X + checkBox.Width + 10, y, nameLabel.Location.X - 10, y ); }
private void InitializeComponent() { this.dataGridView1 = new DataGridView(); this.ItemTemplate = new DataRepeaterItem(); this.name = new DataGridViewTextBoxColumn(); this.Collide = new DataGridViewCheckBoxColumn(); this.Type = new DataGridViewTextBoxColumn(); ((ISupportInitialize)this.dataGridView1).BeginInit(); this.SuspendLayout(); this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange((DataGridViewColumn)this.name, (DataGridViewColumn)this.Collide, (DataGridViewColumn)this.Type); this.dataGridView1.Dock = DockStyle.Fill; this.dataGridView1.Location = new Point(0, 0); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ShowEditingIcon = false; this.dataGridView1.Size = new Size(497, 304); this.dataGridView1.TabIndex = 0; this.dataGridView1.CellEndEdit += new DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit); this.dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(this.dataGridView1_CellValidating); this.ItemTemplate.Size = new Size(232, 100); this.name.HeaderText = "Name"; this.name.Name = "name"; this.name.ReadOnly = true; this.Collide.FlatStyle = FlatStyle.System; this.Collide.HeaderText = "Collide"; this.Collide.Name = "Collide"; this.Type.HeaderText = "Type"; this.Type.MaxInputLength = 8; this.Type.Name = "Type"; this.AutoScaleDimensions = new SizeF(6f, 13f); this.AutoScaleMode = AutoScaleMode.Font; this.ClientSize = new Size(497, 304); this.Controls.Add((Control)this.dataGridView1); this.Name = nameof(zcbType); this.Text = "kclType"; this.FormClosing += new FormClosingEventHandler(this.kclType_FormClosing); this.FormClosed += new FormClosedEventHandler(this.kclType_FormClosed); this.Load += new EventHandler(this.kclType_Load); ((ISupportInitialize)this.dataGridView1).EndInit(); this.ResumeLayout(false); }
private void updateTotal() { decimal split = 0; DataSet dsRepeaterCopy = dsRepeater.Clone(); DataTable dtRepeater1 = dsRepeaterCopy.Tables[0]; dtRepeater1 = repeaterVendorSplit.DataSource as DataTable; /* foreach (DataRepeaterItem item in repeaterVendorSplit.ItemTemplate) * { * split = split + Convert.ToDecimal(item.Controls["txtSplit"].Text.ToString()); * }*/ for (int i = 0; i < repeaterVendorSplit.ItemCount; i++) { repeaterVendorSplit.CurrentItemIndex = i; DataRepeaterItem item = repeaterVendorSplit.CurrentItem; split = split + Convert.ToDecimal(item.Controls["txtSplit"].Text.ToString()); } txtTotalSplit.Value = split; }
public DataRepeaterItemHelper(DataRepeaterItem repeaterItem) { item = repeaterItem; this.AssignHandle(item.Handle); }