This is all of the code regarding my DataGridView. Is there anything that could cause Refresh() not to work?
this.usersDataGridView.AllowUserToAddRows = false;
this.usersDataGridView.AllowUserToDeleteRows = false;
this.usersDataGridView.AutoGenerateColumns = false;
this.usersDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.usersDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.iDDataGridViewTextBoxColumn,
this.uSERNAMEDataGridViewTextBoxColumn,
this.nAMEDataGridViewTextBoxColumn,
this.sURNAMEDataGridViewTextBoxColumn,
this.pASSWORDDataGridViewTextBoxColumn,
this.pERMISSIONDataGridViewTextBoxColumn});
this.usersDataGridView.DataSource = this.usersBindingSource1;
this.usersDataGridView.Location = new System.Drawing.Point(9, 9);
this.usersDataGridView.Name = "usersDataGridView";
this.usersDataGridView.ReadOnly = true;
this.usersDataGridView.Size = new System.Drawing.Size(488, 291);
this.usersDataGridView.TabIndex = 0;
this.usersDataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.usersdataGridView_RowClick);
I apologize in advance if this question has been answered, but I could not find answer that could help me.
try this:
dataGridView1.DataSource = typeof(DataSet);
dataGridView1.DataSource = this.usersBindingSource1;
Related
Here is my code in TreeView in gtk. Please help me im new to gtk
Gtk.TreeViewColumn activeColumn = new Gtk.TreeViewColumn ();
activeColumn.Title = "Active";
activeColumn.Expand = true;
activeColumn.Sizing = TreeViewColumnSizing.Fixed;
activeColumn.MinWidth = 100;
Gtk.CellRendererPixbuf activeCell = new Gtk.CellRendererPixbuf ();
activeColumn.PackStart (activeCell, true);
activeColumn.AddAttribute (activeCell, "pixbuf", 6);
I have created a hierarchical relationship in a RadGridView. But the relationship doesn't work. I can't show the detail information. What do I do wrong?
If I generated automatically all relationships works fine. But I need just one field of one table as detail info.
Further: I use VS2013 Prof., WinForms as UI and LINQ to SQL as datasource.
The source code is:
private void OpenConfigurations()
{
bsConfigurations.DataSource = Db.Configurations.Where(c => c.Active == true && c.CompanyId == CurrentCompany.CompanyId).Select(c => c).OrderBy(c => c.Name);
bsConfigurationContracts.DataSource = Db.ConfigurationContracts.Where(c => c.Contract.InsurranceId == CurrentCompany.CompanyId).Select(c =>
c).OrderBy(c => c.Contract.Name);
GridViewRelation gvrConfigurations = new GridViewRelation();
gvrConfigurations.ChildColumnNames.Add("ConfigurationId");
gvrConfigurations.ChildTemplate = this.gridViewTemplate1;
gvrConfigurations.ParentColumnNames.Add("ConfigurationId");
gvrConfigurations.ParentTemplate = this.gvConfiguration.MasterTemplate;
gvConfiguration.Relations.Add(gvrConfigurations);
}
In the designer:
this.gridViewTemplate1.AllowAddNewRow = false;
gridViewTextBoxColumn1.EnableExpressionEditor = false;
gridViewTextBoxColumn1.FieldName = "Contract.Name";
gridViewTextBoxColumn1.HeaderText = "Name";
gridViewTextBoxColumn1.Name = "colName";
gridViewTextBoxColumn1.Width = 250;
gridViewTextBoxColumn2.EnableExpressionEditor = false;
gridViewTextBoxColumn2.FieldName = "ConfigurationId";
gridViewTextBoxColumn2.HeaderText = "ConfigurationId";
gridViewTextBoxColumn2.IsVisible = false;
gridViewTextBoxColumn2.Name = "colConfigurationId";
this.gridViewTemplate1.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] { gridViewTextBoxColumn1, gridViewTextBoxColumn2 });
this.gridViewTemplate1.DataSource = this.bsConfigurationContracts;
//
// gvConfiguration
//
this.gvConfiguration.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(233)))), ((int)(((byte)(240)))), ((int)(((byte)(249)))));
this.gvConfiguration.Cursor = System.Windows.Forms.Cursors.Default;
this.gvConfiguration.Dock = System.Windows.Forms.DockStyle.Fill;
this.gvConfiguration.Font = new System.Drawing.Font("Segoe UI", 8.25F);
this.gvConfiguration.ForeColor = System.Drawing.Color.Black;
this.gvConfiguration.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.gvConfiguration.Location = new System.Drawing.Point(0, 30);
//
//
//
this.gvConfiguration.MasterTemplate.AllowAddNewRow = false;
this.gvConfiguration.MasterTemplate.AutoGenerateColumns = false;
gridViewTextBoxColumn3.EnableExpressionEditor = false;
gridViewTextBoxColumn3.FieldName = "Name";
gridViewTextBoxColumn3.HeaderText = "Name";
gridViewTextBoxColumn3.Name = "colName";
gridViewTextBoxColumn3.SortOrder = Telerik.WinControls.UI.RadSortOrder.Ascending;
gridViewTextBoxColumn3.Width = 250;
gridViewTextBoxColumn4.EnableExpressionEditor = false;
gridViewTextBoxColumn4.FieldName = "ConfigurationId";
gridViewTextBoxColumn4.HeaderText = "ConfigurationId";
gridViewTextBoxColumn4.IsVisible = false;
gridViewTextBoxColumn4.Name = "colConfigurationId";
this.gvConfiguration.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] { gridViewTextBoxColumn3, gridViewTextBoxColumn4 });
this.gvConfiguration.MasterTemplate.DataSource = this.bsConfigurations;
sortDescriptor1.PropertyName = "colName";
this.gvConfiguration.MasterTemplate.SortDescriptors.AddRange(new Telerik.WinControls.Data.SortDescriptor[] { sortDescriptor1 });
this.gvConfiguration.MasterTemplate.Templates.AddRange(new Telerik.WinControls.UI.GridViewTemplate[] { this.gridViewTemplate1 });
this.gvConfiguration.Name = "gvConfiguration";
this.gvConfiguration.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.gvConfiguration.ShowGroupPanel = false;
this.gvConfiguration.Size = new System.Drawing.Size(1098, 72);
this.gvConfiguration.TabIndex = 4;
this.gvConfiguration.Text = "radGridView1";
this.gvConfiguration.CellDoubleClick += new Telerik.WinControls.UI.GridViewCellEventHandler(this.gvConfiguration_CellDoubleClick);
The solution is in the relation you have to add the column name in stead of the field name.
So this is the right code:
GridViewRelation gvrConfigurations = new GridViewRelation();
gvrConfigurations.ChildColumnNames.Add("colConfigurationId");
gvrConfigurations.ChildTemplate = this.gridViewTemplate1;
gvrConfigurations.ParentColumnNames.Add("colConfigurationId");
gvrConfigurations.ParentTemplate = this.gvConfiguration.MasterTemplate;
gvConfiguration.Relations.Add(gvrConfigurations);
I am trying to get the Telerik RadGridview control to filter, and am not having any luck. I am getting data back, and sorting is working. The FilterExpressionChanged is firing. Can someone spot what I'm doing wrong?
Data retrieval:
public void LoadData()
{
DataSet oDataSet = new DataSet();
using (SqlConnection oConnection = new SqlConnection(frm_Main.GetConnectionString()))
{
using (SqlCommand oCommand = new SqlCommand())
{
oConnection.Open();
oCommand.Connection = oConnection;
oCommand.CommandText = "SELECT * FROM ip.t_Dataload UNION ALL SELECT * FROM ip.t_Dataload_his ORDER BY Started DESC";
using (SqlDataAdapter oDataAdapter = new SqlDataAdapter(oCommand))
{
oDataAdapter.Fill(oDataSet);
radGridView1.DataSource = oDataSet.Tables[0];
}
}
}
}
Form.designer.cs:
//
// radGridView1
//
this.radGridView1.BackColor = System.Drawing.SystemColors.Desktop;
this.radGridView1.CausesValidation = false;
this.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.radGridView1.EnableCustomFiltering = true;
this.radGridView1.Font = new System.Drawing.Font("Segoe UI", 8.25F);
this.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText;
this.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.radGridView1.Location = new System.Drawing.Point(0, 24);
//
// radGridView1
//
this.radGridView1.MasterTemplate.AllowAddNewRow = false;
this.radGridView1.MasterTemplate.AllowDeleteRow = false;
this.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.MasterTemplate.EnableCustomFiltering = true;
this.radGridView1.MasterTemplate.EnableFiltering = true;
this.radGridView1.MasterTemplate.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
this.radGridView1.Name = "radGridView1";
this.radGridView1.NewRowEnterKeyMode = Telerik.WinControls.UI.RadGridViewNewRowEnterKeyMode.None;
this.radGridView1.ReadOnly = true;
this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.radGridView1.ShowGroupPanel = false;
this.radGridView1.Size = new System.Drawing.Size(1277, 746);
this.radGridView1.TabIndex = 2;
this.radGridView1.Text = "radGridView1";
this.radGridView1.EnableFiltering = true;
this.radGridView1.RowFormatting += new Telerik.WinControls.UI.RowFormattingEventHandler(this.radGridView1_RowFormatting);
this.radGridView1.CellFormatting += new Telerik.WinControls.UI.CellFormattingEventHandler(this.radGridView1_CellFormatting);
this.radGridView1.CellDoubleClick += new Telerik.WinControls.UI.GridViewCellEventHandler(this.radGridView1_CellDoubleClick);
this.radGridView1.DataBindingComplete += new Telerik.WinControls.UI.GridViewBindingCompleteEventHandler(this.radGridView1_DataBindingComplete);
this.radGridView1.FilterExpressionChanged += new Telerik.WinControls.UI.GridViewFilterExpressionChangedEventHandler(this.radGridView1_FilterExpressionChanged);
//
If you set
EnableCustomFiltering = true
and
EnableFiltering = true
filtering does not work.
To make the filtering work, set EnableCustomFiltering = false and EnableFiltering = true.
In my Pivot table, I have a data field which I want to be summarized as count. I tried changing the subtotalfunction property to count, but it still shows the sum. Can someone give me an example of how I can do this?
In other words can anyone give me an example of a pivot table in which you can see the count and not the sum.
I'm using EPPlus latest build. 3.1.1
Thanks a lot :)
EDIT: This is what I'm trying.
var wsPivot = package.Workbook.Worksheets.Add("Pivot");
var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A55"], dataRange, "Table");
pivotTable.MultipleFieldFilters = true;
pivotTable.RowGrandTotals = true;
pivotTable.ColumGrandTotals = true;
pivotTable.Compact = true;
pivotTable.CompactData = true;
pivotTable.GridDropZones = false;
pivotTable.Outline = false;
pivotTable.OutlineData = false;
pivotTable.ShowError = true;
pivotTable.ErrorCaption = "[error]";
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
pivotTable.FirstDataCol = 3;
pivotTable.RowHeaderCaption = "Caption";
var pageField = pivotTable.Fields["field1"];
pivotTable.PageFields.Add(pageField);
var rowField = pivotTable.Fields["cust"];
pivotTable.RowFields.Add(rowField);
var dataField = pivotTable.Fields["id"];
dataField.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.Count;
pivotTable.DataFields.Add(dataField);
I figured it out. This worked for me
pivotTable.DataFields.Add(dataField);
pivotTable.DataFields[0].Function = DataFieldFunctions.Count;
This is my findings,
Dim Field As ExcelPivotTableField = pivotTable.Fields(strFieldName)
Dim DataField As ExcelPivotTableDataField = pivotTable.DataFields.Add(Field)
DataField.Function = DataFieldFunctions.Sum
I have added button to datagrid view but when ever the function is called more than once then new button adds I need to stop this addition
void AddtoGrid()
{
try
{
table = new DataTable();
bcol = new DataGridViewButtonColumn();
bcol.HeaderText = "Action ";
bcol.Text = "Delete";
bcol.Name = "deleteUserButton";
bcol.UseColumnTextForButtonValue = true;
table.Columns.Add("Name");
table.Columns.Add("Type");
table.Columns.Add("Status");
table.Columns.Add("Date Created");
table.Columns.Add("Action");
for (int i = 0; i < userAction.UserName.ToArray().Length; i++)
{
row = table.NewRow();
asc.Add(userAction.UserName[i]);
row["Name"] = userAction.UserName[i];
row["Type"] = userAction.UserType[i];
row["Status"] = userAction.UserStatus[i];
row["Date Created"] = userAction.DateCrea[i];
row["Action"] = bcol.Text;
table.Rows.Add(row);
}
UsersView.DataSource = table;
UsersView.AllowUserToAddRows = false;//To remove extra row at the end
UsersView.Columns.Add(bcol);
}
catch (Exception ca)
{
MessageBox.Show(ca.ToString());
}
}//End Function for Getting Present Users
I'm not quite sure I understand your question, though I believe that you need to encapsulate creation of the new column into it's own method and only call it once - in the constructor for instance.
For example:
void CreateDeleteColumn()
{
bcol = new DataGridViewButtonColumn();
bcol.HeaderText = "Action ";
bcol.Text = "Delete";
bcol.Name = "deleteUserButton";
bcol.UseColumnTextForButtonValue = true;
UsersView.Columns.Add(bcol);
}
That should stop it adding a column every time you populate the list view.
Hope this helps and sorry if I misunderstood.
Tony