void DataList_Loaded(object sender, RoutedEventArgs e) { this.SelectionChanged += new SelectionChangedEventHandler(DataList_SelectionChanged); //e.Handled = true; if (this.Template.FindName("PART_List", this) != null) { if (!this.GridViewColumnsCalculated) { ListView lv = this.Template.FindName("PART_List", this) as ListView; GridView gv = lv.View as GridView; if (gv == null) { return; } foreach (GridViewColumn gvc in gv.Columns) { if (gvc.Width > 0) { //has a set width GridViewColumns.Add(gvc); } } this.GridViewColumnsCalculated = true; } else { } this.SizeChangedAction(); } }
private void button4_Click(object sender, EventArgs e) { DataTable dt = GridViewColumns.DataSource as DataTable; DataRow dr = dt.NewRow(); txtcolName.Text = ""; txtcolCaption.Text = ""; txtcolType.Text = ""; txtcolWidth.Text = ""; txtcolDefaultValue.Text = ""; txtcolDataSource.Text = ""; txtcolValueMember.Text = ""; txtcolDisplayMember.Text = ""; txtcolFooterName.Text = ""; txtcolFooterType.Text = ""; dt.Rows.Add(dr); GridViewColumns.ClearSelection(); GridViewColumns.CurrentCell = GridViewColumns.Rows[GridViewColumns.Rows.Count - 1].Cells[0]; //GridViewColumns.Rows[GridViewColumns.Rows.Count - 1].Selected = true; }