WPF datagrid Gantt calendar - c#

I use datagrid DataGridTemplateColumn which HeaderTemplate is custom user control to generate my timeline and that control fill entire datagrid cell to get the desired result. But with this solution I got selection problem which during the selection of cells border are invisible. To overcome problem made a temporary solution with popup.
enter image description here
But what I'm interested in is how to make selection border over my custom HeaderTemplate to get result like in picture.enter image description here
Thanks in advance.
public void Init()
{
gridKalendar.AutoGenerateColumns =false;
gridKalendar.EnableColumnVirtualization = true;
gridKalendar.EnableRowVirtualization = true;
gridKalendar.CanUserAddRows = false;
gridKalendar.CanUserReorderColumns = false;
gridKalendar.CanUserSortColumns = false;
gridKalendar.CanUserResizeColumns = false;
gridKalendar.CanUserResizeRows =false;
gridKalendar.SetValue(VirtualizingPanel.VirtualizationModeProperty, VirtualizationMode.Recycling);
gridKalendar.SetValue(VirtualizingPanel.IsVirtualizingWhenGroupingProperty, false);
gridKalendar.SetValue(VirtualizingPanel.IsVirtualizingProperty, true);
gridKalendar.SetValue(ScrollViewer.CanContentScrollProperty, false);
gridKalendar.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
gridKalendar.SelectionMode = DataGridSelectionMode.Extended;
gridKalendar.GridLinesVisibility = DataGridGridLinesVisibility.Horizontal;
gridKalendar.FrozenColumnCount = 3;
gridKalendar.SelectionUnit = DataGridSelectionUnit.Cell;
var klikkonverter = new KlikConverter();
var converter = new BackGroundConverter();
var vrednostconverter = new VrednostConverter();
var hderkonverter = new HederConverter();
var godina = DateTime.Now.Year;
var detaljiKonverter = new DetaljiConverter();
var vizuelizacijaTastera = new VizuelizacijaTasteraConverter();
var brojBKkonverter = new BrojBukingaConverter();
var brojRezervacijeKonverter = new BrojRezervacijeConverter();
var klikZaKontrolu = new KlikZaKontroluConverter();
DateTime DatumPocetakKalendar = (DateTime)PostaviKalendarNaDanPocetak;
DateTime DatumKrajKalendar = (DateTime)PostaviKalendarNaDanKraj;
if (DatumPocetakKalendar != null && DatumKrajKalendar != null)
{
while (DatumPocetakKalendar < DatumKrajKalendar)
{
#region poboljsani tem
DataGridTemplateColumn kolona = new DataGridTemplateColumn();
kolona.Header = string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar);
DataTemplate dataTemplejt = new DataTemplate();
DataTemplate dataTemplejtHeder = new DataTemplate();
FrameworkElementFactory kalendarKRK = new FrameworkElementFactory(typeof(KalendarKRK));
FrameworkElementFactory kalendarKRKdatum = new FrameworkElementFactory(typeof(KalendarKRKDatum));
#region Generisanje celije
kalendarKRK.SetValue(KalendarKRK.ImeGostaPropery, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)){ Converter = vrednostconverter });
kalendarKRK.SetValue(KalendarKRK.BojaKalendaraProperty, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter = converter });
kalendarKRK.SetValue(KalendarKRK.PrikazTasteraDetaljaProperty, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter = detaljiKonverter });
kalendarKRK.SetValue(KalendarKRK.VizuelizacijaTasteraProperty, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter = vizuelizacijaTastera });
kalendarKRK.SetValue(KalendarKRK.BrojBukingaProperty, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter = brojBKkonverter });
kalendarKRK.SetValue(KalendarKRK.BrojRezervacijeProperty, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter =brojRezervacijeKonverter });
kalendarKRK.SetValue(KalendarKRK.OstaleKoloneKlikPropery, new Binding(string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar)) { Converter = klikZaKontrolu });
#endregion
#region Generisanje hedera sa datumima
kalendarKRKdatum.SetValue(KalendarKRKDatum.CeoDatumProperty,string.Format("{0:yyyy-MM-dd}", DatumPocetakKalendar.Date).ToString());//yyyy/MM/dd
kalendarKRKdatum.SetValue(KalendarKRKDatum.DanProperty, string.Format("{0:dddd}", DatumPocetakKalendar.Date).ToString());
#endregion
#region stilovi
kolona.HeaderStyle = new Style(typeof(System.Windows.Controls.Primitives.DataGridColumnHeader));
kolona.HeaderStyle.Setters.Add(new Setter{ Property = System.Windows.Controls.Primitives.DataGridColumnHeader.BackgroundProperty, Value = ObojiVikende(DatumPocetakKalendar)});
kolona.HeaderStyle.Setters.Add(new Setter {Property = DataGridColumnHeader.MarginProperty, Value = new Thickness(0) });
kolona.HeaderStyle.Setters.Add(new Setter{Property = DataGridColumnHeader.BorderThicknessProperty, Value = new Thickness(0)});
kolona.HeaderStyle.Setters.Add(new Setter{Property = DataGridColumnHeader.VerticalContentAlignmentProperty, Value =VerticalAlignment.Stretch });
kolona.HeaderStyle.Setters.Add(new Setter{Property = DataGridColumnHeader.HorizontalContentAlignmentProperty, Value = HorizontalAlignment.Stretch });
kolona.HeaderStyle.Setters.Add(new Setter{Property = DataGridColumnHeader.VerticalAlignmentProperty,Value = VerticalAlignment.Stretch });
kolona.HeaderStyle.Setters.Add(new Setter {Property = DataGridColumnHeader.HorizontalAlignmentProperty,Value = HorizontalAlignment.Stretch});
kolona.CellStyle = new Style(typeof(DataGridCell));
kolona.CellStyle.Setters.Add(new Setter{Property = DataGridCell.BorderThicknessProperty,Value = new Thickness(0)});
kolona.CellStyle.Setters.Add(new Setter{Property = DataGridCell.MarginProperty,Value = new Thickness(0)});
kolona.CellStyle.Setters.Add(new Setter{Property = DataGridCell.VerticalAlignmentProperty,Value = VerticalAlignment.Stretch });
kolona.CellStyle.Setters.Add(new Setter {Property = DataGridCell.HorizontalAlignmentProperty,Value = HorizontalAlignment.Stretch });
#endregion
#region Zumiranje
//Binding bind = new Binding();// {Path=System.Windows.Controls.Slider.ValueProperty.ToString(), ElementName=ZumiranjeKolone.Name};
//bind.Source = ZumiranjeKolone;
//bind.Path = new PropertyPath(System.Windows.Controls.ComboBox.SelectedValueProperty);
//ScaleTransform st = new ScaleTransform();
//BindingOperations.SetBinding(dataGridLength.Value, WidthProperty, bind);
//BindingOperations.SetBinding(st, ScaleTransform.ScaleXProperty, bind);
//BindingOperations.SetBinding(st, ScaleTransform.ScaleYProperty, bind);
double w = 80;
kalendarKRK.SetValue(KalendarKRK.ZumiranjePropery,w);
kalendarKRKdatum.SetValue(KalendarKRKDatum.ZumiranjePropery, w);
kolona.Width = DataGridLength.SizeToCells;
#endregion
dataTemplejtHeder.VisualTree = kalendarKRKdatum;
dataTemplejt.VisualTree = kalendarKRK;
kolona.CellTemplate = dataTemplejt;
kolona.HeaderTemplate = dataTemplejtHeder;
gridKalendar.Columns.Add(kolona);
#endregion
DatumPocetakKalendar = DatumPocetakKalendar.AddDays(1);
}
}

Related

Removing the cell borders from header in DataGridView C#

enter image description here
I am using a DataGridView in C# and I wanted to remove the Cell Border of DataGridView.
dataGrid = new DataGridView();
dataGrid.BackgroundColor = Control.DefaultBackColor;
dataGrid.AdvancedColumnHeadersBorderStyle = DataGridViewAdvancedCellBorderStyle.None;
dataGrid.AdvancedRowHeadersBorderStyle = DataGridViewAdvancedCellBorderStyle.None;
dataGrid.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(dataGrid_CellClick);
dataGrid.CellMouseEnter += new System.Windows.Forms.DataGridViewCellEventHandler(dataGrid_CellMouseEnter);
dataGrid.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(dataGrid_DataBindingComplete);
dataGrid.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGrid_CellPainting);
dataGrid.DataSource = this._lstWorklet;
dataGrid.Columns.Add("Action", "Action");
dataGrid.Size = new System.Drawing.Size(1018, 434);
dataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
dataGrid.DefaultCellStyle.SelectionBackColor = dataGrid.DefaultCellStyle.BackColor;
dataGrid.DefaultCellStyle.SelectionForeColor = dataGrid.DefaultCellStyle.ForeColor;
dataGrid.ReadOnly = true;
dataGrid.RowTemplate.Height = 48;
dataGrid.ColumnHeadersHeight = 48;
dataGrid.RowHeadersVisible = false;
dataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGrid.ColumnHeadersDefaultCellStyle.Font = new Font(dataGrid.Font, FontStyle.Bold);
dataGrid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGrid.MultiSelect = false;

requests[0]' (oneof), oneof field 'kind' is already set. Cannot set 'updateCell encountered when generating checkbox

I'm trying to generate a checkbox from C#.net using google sheets API but I'm encountering the oneof field kind is already set error. I tried combining extendedValue and DataValidation. Please see code snippet below:
ConditionValue conditionValueTrue = new ConditionValue();
conditionValueTrue.UserEnteredValue = "TRUE";
ConditionValue conditionValueFalse = new ConditionValue();
conditionValueFalse.UserEnteredValue = "FALSE";
ConditionValue[] validValues = { conditionValueTrue, conditionValueFalse };
BooleanCondition bc = new BooleanCondition();
bc.Type = "BOOLEAN";
bc.Values = validValues;
DataValidationRule dataValidationRule = new DataValidationRule();
dataValidationRule.Condition = bc;
dataValidationRule.ShowCustomUi = true;
GridRange validationRange = new GridRange();
validationRange.StartColumnIndex = 7;
validationRange.EndColumnIndex = 7;
validationRange.SheetId = 0;
SetDataValidationRequest setDataValidationRequest = new SetDataValidationRequest();
setDataValidationRequest.Rule = dataValidationRule;
setDataValidationRequest.Range = validationRange;
ExtendedValue extendedValue = new ExtendedValue();
extendedValue.BoolValue = true;
BatchUpdateSpreadsheetRequest busr = new BatchUpdateSpreadsheetRequest();
busr.Requests = new List<Request>();
Request r = new Request();
busr.Requests.Add(r);
r.UpdateCells = new UpdateCellsRequest();
r.SetDataValidation = setDataValidationRequest;
var gc = new GridCoordinate();
gc.ColumnIndex = 7;
gc.RowIndex = row;
gc.SheetId = 0;
r.UpdateCells.Start = gc;
r.UpdateCells.Fields = "*";
r.UpdateCells.Rows = new List<RowData>();
var rd = new RowData();
r.UpdateCells.Rows.Add(rd);
rd.Values = new List<CellData>();
var cd = new CellData();
cd.UserEnteredValue = extendedValue;
rd.Values.Add(cd);
SpreadsheetsResource.BatchUpdateRequest bur = _sheetsService.Spreadsheets.BatchUpdate(busr, SpreadsheetId);
bur.Execute();

How to display milliseconds into “days : hours : minutes : seconds” in Infragistics UltraChart?

I'm using Infragistics UltraChart controls for displaying graphs. (Version 19.1)
My line chart graph is as below
Here Y-axis is noting but milliseconds(turn around time of Int64 type), I want to display it like "days:hh:mm:ss" format. Is it possible to display Y- axis lables in this format? while X axis is showing list of sample names (Which is of string type) The Ultra line chart data binding code is as below
ultraChartTAT.Data.DataSource = dsTAT.Tables["dtTAT"];
ultraChartTAT.Data.DataBind();
Here ultraChartTAT is an UltraChart infragistic control and dsTAT is a DataSet. The dsTAT.Tables["dtTAT"] design structure is as below
DataTable dtTAT = new DataTable("dtTAT");
dtTAT.Columns.Add("TAT", typeof(string));
dtTAT.Columns.Add("Sample1", typeof(Int64));
dtTAT.Columns.Add("Sample2", typeof(Int64));
dtTAT.Columns.Add("Sample3", typeof(Int64));
dtTAT.Columns.Add("Sample4", typeof(Int64));
dtTAT.Columns.Add("Sample5", typeof(Int64));
dtTAT.Columns.Add("Sample6", typeof(Int64));
dtTAT.Columns.Add("Sample7", typeof(Int64));
dtTAT.Columns.Add("Sample8", typeof(Int64));
For more reference take a look on this link https://stackoverflow.com/a/36329469/4524485
In case if any other information is required then add it in comment I'll update my question accordingly.
To format data for the X/Y axis labels the IRenderLabel interface can be used.
In example below the DateTimeRenderer class is using the IRenderLabel interface implementation to display Y-axis labels in the DateTime format:
For additional information see the Infragistics documentation:
http://help.infragistics.com/Help/Doc/WinForms/2011.1/CLR2.0/html/Chart_Customize_Labels_Using_the_IRenderLabel_Interface.html
DateTimeRenderer.cs
using Infragistics.UltraChart.Resources;
using System;
using System.Collections;
using System.Data;
namespace UltraGrid
{
public class DateTimeRenderer : IRenderLabel
{
readonly DataTable source;
public DateTimeRenderer(DataTable dt)
{
source = dt;
}
public string ToString(Hashtable context)
{
double dataValue = (double)context["DATA_VALUE"];
var dt = new DateTime((long)dataValue);
return dt.ToString("MM/dd/yyyy HH:mm:ss");
}
}
}
Form1.cs
using System;
using System.Collections;
using System.Data;
using System.Windows.Forms;
namespace UltraGrid
{
public partial class Form1 : Form
{
DataTable table = new DataTable("Statistics");
public Form1()
{
InitializeComponent();
// Create columns to hold sample data.
var column1 = new DataColumn("Sample", typeof(string));
var column2 = new DataColumn("Line1", typeof(Int64));
var column3 = new DataColumn("Line2", typeof(Int64));
var column4 = new DataColumn("Line3", typeof(Int64));
table.Columns.AddRange(new DataColumn[] { column1, column2, column3, column4 });
var now = DateTime.Now.Ticks;
var rnd = new Random();
for (int i = 1; i < 20; i++)
{
table.Rows.Add(new object[] { "Sample" + i.ToString(), now + rnd.Next(999, 3600000)*1000, now + rnd.Next(999, 3600000)*1000, now + rnd.Next(999, 3600000)*1000 });
}
}
private void LineChartStyles_Load(object sender, System.EventArgs e)
{
this.ultraChart1.Data.DataSource = table;
ultraChart1.Axis.Y.Labels.ItemFormatString = "<MY_VALUE>";
ultraChart1.Tooltips.FormatString = "<MY_VALUE>";
var MyLabelHashTable = new Hashtable { { "MY_VALUE", new DateTimeRenderer(table) } };
this.ultraChart1.LabelHash = MyLabelHashTable;
this.ultraChart1.Data.DataBind();
}
}
}
Form1.Designer.cs
namespace UltraGrid
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement1 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement2 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement3 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement4 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement5 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement6 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.LineChartAppearance lineChartAppearance1 = new Infragistics.UltraChart.Resources.Appearance.LineChartAppearance();
Infragistics.UltraChart.Resources.Appearance.LineAppearance lineAppearance1 = new Infragistics.UltraChart.Resources.Appearance.LineAppearance() { Thickness = 3 };
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement7 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.LineAppearance lineAppearance2 = new Infragistics.UltraChart.Resources.Appearance.LineAppearance() { Thickness = 3 };
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement8 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
Infragistics.UltraChart.Resources.Appearance.LineAppearance lineAppearance3 = new Infragistics.UltraChart.Resources.Appearance.LineAppearance() { Thickness = 3 };
Infragistics.UltraChart.Resources.Appearance.PaintElement paintElement9 = new Infragistics.UltraChart.Resources.Appearance.PaintElement();
this.ultraChart1 = new Infragistics.Win.UltraWinChart.UltraChart();
((System.ComponentModel.ISupportInitialize)(this.ultraChart1)).BeginInit();
this.SuspendLayout();
this.ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;
//
// ultraChart1
//
resources.ApplyResources(this.ultraChart1, "ultraChart1");
this.ultraChart1.Axis.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(220)))));
paintElement1.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.None;
paintElement1.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(220)))));
this.ultraChart1.Axis.PE = paintElement1;
this.ultraChart1.Axis.X.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.X.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>";
this.ultraChart1.Axis.X.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
this.ultraChart1.Axis.X.Labels.SeriesLabels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.X.Labels.SeriesLabels.FormatString = "";
this.ultraChart1.Axis.X.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.X.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
this.ultraChart1.Axis.X.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.X.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.X.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.X.Labels.Visible = true;
this.ultraChart1.Axis.X.LineThickness = 1;
this.ultraChart1.Axis.X.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.X.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.X.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.X.MajorGridLines.Visible = true;
this.ultraChart1.Axis.X.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.X.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.X.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.X.MinorGridLines.Visible = false;
this.ultraChart1.Axis.X.Visible = true;
this.ultraChart1.Axis.X2.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.X2.Labels.HorizontalAlign = System.Drawing.StringAlignment.Far;
this.ultraChart1.Axis.X2.Labels.ItemFormatString = "<ITEM_LABEL>";
this.ultraChart1.Axis.X2.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
this.ultraChart1.Axis.X2.Labels.SeriesLabels.FormatString = "";
this.ultraChart1.Axis.X2.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Far;
this.ultraChart1.Axis.X2.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
this.ultraChart1.Axis.X2.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.X2.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.X2.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.X2.Labels.Visible = false;
this.ultraChart1.Axis.X2.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.X2.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.X2.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.X2.MajorGridLines.Visible = true;
this.ultraChart1.Axis.X2.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.X2.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.X2.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.X2.MinorGridLines.Visible = false;
this.ultraChart1.Axis.X2.Visible = false;
this.ultraChart1.Axis.Y.Extent = 110;
this.ultraChart1.Axis.Y.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.Y.Labels.HorizontalAlign = System.Drawing.StringAlignment.Far;
this.ultraChart1.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:00.##>";
this.ultraChart1.Axis.Y.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Y.Labels.SeriesLabels.FormatString = "";
this.ultraChart1.Axis.Y.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Far;
this.ultraChart1.Axis.Y.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Y.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Y.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.Y.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Y.Labels.Visible = true;
this.ultraChart1.Axis.Y.LineThickness = 1;
this.ultraChart1.Axis.Y.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Y.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.Y.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Y.MajorGridLines.Visible = true;
this.ultraChart1.Axis.Y.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Y.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.Y.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Y.MinorGridLines.Visible = false;
this.ultraChart1.Axis.Y.TickmarkInterval = 50D;
this.ultraChart1.Axis.Y.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart;
this.ultraChart1.Axis.Y.Visible = true;
this.ultraChart1.Axis.Y2.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.Y2.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Y2.Labels.ItemFormatString = "<DATA_VALUE:00.##>";
this.ultraChart1.Axis.Y2.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Y2.Labels.SeriesLabels.FormatString = "";
this.ultraChart1.Axis.Y2.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Y2.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Y2.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Y2.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.Y2.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Y2.Labels.Visible = false;
this.ultraChart1.Axis.Y2.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Y2.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.Y2.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Y2.MajorGridLines.Visible = true;
this.ultraChart1.Axis.Y2.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Y2.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.Y2.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Y2.MinorGridLines.Visible = false;
this.ultraChart1.Axis.Y2.Visible = false;
this.ultraChart1.Axis.Z.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.Z.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Z.Labels.ItemFormatString = "";
this.ultraChart1.Axis.Z.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Z.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Z.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Z.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Z.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.Z.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Z.Labels.Visible = true;
this.ultraChart1.Axis.Z.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Z.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.Z.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Z.MajorGridLines.Visible = true;
this.ultraChart1.Axis.Z.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Z.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.Z.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Z.MinorGridLines.Visible = false;
this.ultraChart1.Axis.Z.Visible = false;
this.ultraChart1.Axis.Z2.Labels.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Axis.Z2.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Z2.Labels.ItemFormatString = "";
this.ultraChart1.Axis.Z2.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Z2.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Near;
this.ultraChart1.Axis.Z2.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
this.ultraChart1.Axis.Z2.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Z2.Labels.SeriesLabels.Visible = true;
this.ultraChart1.Axis.Z2.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
this.ultraChart1.Axis.Z2.Labels.Visible = false;
this.ultraChart1.Axis.Z2.MajorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Z2.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
this.ultraChart1.Axis.Z2.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Z2.MajorGridLines.Visible = true;
this.ultraChart1.Axis.Z2.MinorGridLines.AlphaLevel = ((byte)(255));
this.ultraChart1.Axis.Z2.MinorGridLines.Color = System.Drawing.Color.LightGray;
this.ultraChart1.Axis.Z2.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
this.ultraChart1.Axis.Z2.MinorGridLines.Visible = false;
this.ultraChart1.Axis.Z2.Visible = false;
this.ultraChart1.Border.CornerRadius = 5;
this.ultraChart1.ColorModel.AlphaLevel = ((byte)(150));
this.ultraChart1.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.CustomLinear;
paintElement2.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient;
paintElement2.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(108)))), ((int)(((byte)(162)))), ((int)(((byte)(36)))));
paintElement2.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.Horizontal;
paintElement2.FillStopColor = System.Drawing.Color.FromArgb(((int)(((byte)(148)))), ((int)(((byte)(244)))), ((int)(((byte)(17)))));
paintElement2.Stroke = System.Drawing.Color.Transparent;
paintElement3.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient;
paintElement3.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(7)))), ((int)(((byte)(108)))), ((int)(((byte)(176)))));
paintElement3.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.Horizontal;
paintElement3.FillStopColor = System.Drawing.Color.FromArgb(((int)(((byte)(53)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
paintElement3.Stroke = System.Drawing.Color.Transparent;
paintElement4.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient;
paintElement4.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(0)))), ((int)(((byte)(5)))));
paintElement4.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.Horizontal;
paintElement4.FillStopColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(117)))), ((int)(((byte)(16)))));
paintElement4.Stroke = System.Drawing.Color.Transparent;
paintElement5.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient;
paintElement5.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(190)))), ((int)(((byte)(2)))));
paintElement5.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.Horizontal;
paintElement5.FillStopColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(81)))));
paintElement5.Stroke = System.Drawing.Color.Transparent;
paintElement6.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient;
paintElement6.Fill = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(122)))), ((int)(((byte)(10)))));
paintElement6.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.Horizontal;
paintElement6.FillStopColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(208)))), ((int)(((byte)(66)))));
paintElement6.Stroke = System.Drawing.Color.Transparent;
this.ultraChart1.ColorModel.Skin.PEs.AddRange(new Infragistics.UltraChart.Resources.Appearance.PaintElement[] {
paintElement2,
paintElement3,
paintElement4,
paintElement5,
paintElement6});
this.ultraChart1.Data.EmptyStyle.LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dash;
this.ultraChart1.Data.SwapRowsAndColumns = true;
this.ultraChart1.ForeColor = System.Drawing.SystemColors.ControlText;
this.ultraChart1.Legend.Font = new System.Drawing.Font("Verdana", 7F);
this.ultraChart1.Legend.Location = Infragistics.UltraChart.Shared.Styles.LegendLocation.Top;
this.ultraChart1.Legend.Visible = true;
lineAppearance1.IconAppearance.CharacterFont = new System.Drawing.Font("Microsoft Sans Serif", 12F);
paintElement7.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.None;
lineAppearance1.IconAppearance.PE = paintElement7;
lineAppearance1.Key = "Monday";
paintElement8.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.None;
lineAppearance2.IconAppearance.PE = paintElement8;
lineAppearance2.Key = "Tuesday";
lineAppearance2.LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dash;
paintElement9.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.None;
lineAppearance3.IconAppearance.PE = paintElement9;
lineAppearance3.Key = "Wednesday";
lineAppearance3.LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
lineChartAppearance1.LineAppearances.Add(lineAppearance1);
lineChartAppearance1.LineAppearances.Add(lineAppearance2);
lineChartAppearance1.LineAppearances.Add(lineAppearance3);
this.ultraChart1.LineChart = lineChartAppearance1;
this.ultraChart1.Name = "ultraChart1";
this.ultraChart1.Tooltips.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F);
this.ultraChart1.Tooltips.HighlightFillColor = System.Drawing.Color.DimGray;
this.ultraChart1.Tooltips.HighlightOutlineColor = System.Drawing.Color.DarkGray;
//
// Form1
//
this.BackColor = System.Drawing.Color.White;
resources.ApplyResources(this, "$this");
this.Controls.Add(this.ultraChart1);
this.Name = "Form1";
this.Load += new System.EventHandler(this.LineChartStyles_Load);
((System.ComponentModel.ISupportInitialize)(this.ultraChart1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Infragistics.Win.UltraWinChart.UltraChart ultraChart1;
}
}

Extended DataGridView does not apply changes

I extended a DataGridView but unfortunately, after using a template from Toolbox, it generates default parameters for me. It looks like it overrides my settings. What im doing wrong here?
class CustomDataGrid2 : DataGridView
{
public CustomDataGrid2() : base()
{
base.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
base.ColumnHeadersHeight = 23;
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
base.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
base.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlDark;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
base.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
base.EnableHeadersVisualStyles = false;
base.Location = new System.Drawing.Point(112, 186);
base.RowHeadersVisible = false;
base.Size = new System.Drawing.Size(401, 150);
}
}
Result:
//
// customDataGrid21
//
this.customDataGrid21.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.customDataGrid21.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlDark;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.customDataGrid21.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.customDataGrid21.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.customDataGrid21.EnableHeadersVisualStyles = false;
this.customDataGrid21.Location = new System.Drawing.Point(60, 138);
this.customDataGrid21.Name = "customDataGrid1";
this.customDataGrid21.RowHeadersVisible = false;
this.customDataGrid21.Size = new System.Drawing.Size(401, 150);
this.customDataGrid21.TabIndex = 3;
As you can see I set DataGridViewColumnHeadersHeightSizeMode.DisableResizing but it generated AutoSize
I also tried:
class CustomDataGrid4 : DataGridView
{
public CustomDataGrid4() : base()
{
}
protected override void OnLayout(LayoutEventArgs e)
{
base.OnLayout(e);
base.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
base.ColumnHeadersHeight = 23;
}
}
Result:
//
// customDataGrid41
//
this.customDataGrid41.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.customDataGrid41.Location = new System.Drawing.Point(96, 152);
this.customDataGrid41.Name = "customDataGrid41";
this.customDataGrid41.Size = new System.Drawing.Size(240, 150);
this.customDataGrid41.TabIndex = 3;
Solution:
class CustomDataGrid6 : DataGridView
{
private DataGridViewColumnHeadersHeightSizeMode m_ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
private int m_columnHeadersHeight = 23;
public new DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode
{
get => this.m_ColumnHeadersHeightSizeMode;
set
{
this.m_ColumnHeadersHeightSizeMode = value;
base.ColumnHeadersHeightSizeMode = this.m_ColumnHeadersHeightSizeMode;
}
}
public int ColumnHeadersHeight
{
get => this.m_columnHeadersHeight;
set
{
this.m_columnHeadersHeight = value;
base.ColumnHeadersHeight = this.m_columnHeadersHeight;
}
}
}
Set the property in the overridden OnLayout() method:
MSDN: Derived classes should override this method to do any custom layout
logic.
private DataGridViewColumnHeadersHeightSizeMode m_ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
public CustomDGV() { }
protected override void OnLayout(LayoutEventArgs e)
{
base.OnLayout(e);
base.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
}
public new DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode
{
get => this.m_ColumnHeadersHeightSizeMode;
set { this.m_ColumnHeadersHeightSizeMode = value;
base.ColumnHeadersHeightSizeMode = this.m_ColumnHeadersHeightSizeMode;
}
}
When you will drop the Custom Control on a Form, DataGridViewColumnHeadersHeightSizeMode.DisableResizing will be the applied value for ColumnHeadersHeightSizeMode
Try it with a Label.AutoSize property. Autosize = false will be set in the Designer only when set in the OnLayout() method.

How can I show labels on sharpmap using PostgreSQL in c#?

VectorLayer v = new VectorLayer("Point", new PostGIS("server=localhost;port=5433;user=postgres;pwd=9839757437;database=OSM3", "GhanaRegions", "Geometry", "id"));
VectorLayer v1 = new VectorLayer("Point", new PostGIS("server=localhost;port=5433;user=postgres;pwd=9839757437;database=OSM3", "ghanalocation", "geometry", "id"));
v.Style.EnableOutline = true;
v.Style.Outline = Pens.Black;
v.Style.Fill = Brushes.Red;
v1.Style.PointColor = Brushes.White;
SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Name");
layLabel.DataSource = new PostGIS("server=localhost;port=5433;user=postgres;pwd=9839757437;database=OSM3", "citie33", "geometry", "id");
layLabel.Enabled = true;
layLabel.LabelColumn = "Name";
layLabel.MaxVisible = 2;
layLabel.MaxVisible = 190;
layLabel.MinVisible = 130;
layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;
layLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection;
layLabel.PriorityColumn = "id";
layLabel.Style.ForeColor = Color.Beige;
layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12);
layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0));
layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center;
// map.Layers.Add(v1);
map.Layers.Add(v);
layLabel.Style.CollisionDetection = true;
map.ZoomToExtents();
pictureBox1.Image = map.GetMap();

Categories