/// Bind data to the control. public override void DataBind() { // Clear the child view state. if (this.HasChildViewState) { this.ClearChildViewState(); } // Let's not create the child controls. this.ChildControlsCreated = true; // Delete the rows from the table. this.rows_ = 0; this.Rows.Clear(); // Create the first row for the table. LogFormatRow row = this.NewRow(); // Initailize the data for this row. row.AddRange(this.formats_.ToArray()); row.SelectedValue = this.formats_[0].ID; // Increment the number of rows. this.rows_ = 1; }
private LogFormatRow NewRow() { LogFormatRow row = new LogFormatRow(); this.Rows.Add(row); row.SelectionChanged += new EventHandler(this.handle_selection_changed); row.SelectionChanging += new EventHandler(this.handle_selection_changing); return(row); }
private void handle_selection_changed(object sender, EventArgs e) { // Get the index of the row. LogFormatRow row = (LogFormatRow)sender; int index = this.Rows.GetRowIndex(row); for (int i = 0; i < this.rows_; ++i) { if (i != index) { // Remove the current selection. row.Remove(row.SelectedItem); // Insert the previous selection. row.Add(this.prev_selection_); } } }
public void IncreaseLogFormats() { // Create a new log format. this.EnsureChildControls(); LogFormatRow row = this.NewRow(); // Get the log formats from the last row. LogFormatRow lastrow = (LogFormatRow)this.Rows[this.rows_ - 1]; LogFormats formats = new LogFormats(lastrow.LogFormats.ToArray()); // Remove last row's selected log format from all rows. LogFormat format = lastrow.SelectedItem; formats.Remove(format); int lastindex = this.rows_ - 1; for (int i = 0; i < this.rows_; ++i) { // Get the current row. LogFormatRow currrow = (LogFormatRow)this.Rows[i]; // Remove the previously selected format from the row. if (i != lastindex) { currrow.Remove(format); } // Remove the newly selected format from the row. currrow.Remove(formats[0]); } // Initialize the contents of the row. row.AddRange(formats.ToArray()); row.SelectedValue = formats[0].ID; // Increment the row count. ++this.rows_; }
private void handle_selection_changing(object sender, EventArgs e) { LogFormatRow row = (LogFormatRow)sender; this.prev_selection_ = row.SelectedItem; }