dockControl = new ChartDockControl(textBox);
dockControl.Alignment = ChartAlignment.Center;
dockControl.Position = ChartDock.Top;
dockControl.Size = new Size(500, 40);
textBox.Name = "title";
textBox.Dock = DockStyle.Fill;
textBox.Font = new Font(new FontFamily("arial"), 28, FontStyle.Bold);
textBox.BorderStyle = BorderStyle.None;
textBox.WordWrap = true;
textBox.LostFocus += TextBox_LostFocus;
textBox.Text = "Syncfusion Chart";
dockControl.Controls.Add(textBox);
dockControl.BringToFront();
dockControl.Visible = false;
this.chartControl1.Controls.Add(dockControl);
this.chartControl1.DockingManager.Add(dockControl);
chartTitle.Text = "Syncfusion Chart";
chartTitle.Font = new Font(new FontFamily("arial"), 28, FontStyle.Bold);
chartTitle.Dock = DockStyle.Fill;
chartTitle.Position = ChartDock.Top;
chartTitle.DoubleClick += Title_DoubleClick;
. . .
. . .
private void TextBox_LostFocus(object sender, System.EventArgs e)
{
var textBox = sender as TextBox;
chartTitle.Text = textBox.Text;
chartTitle.Visible = true;
dockControl.Visible = false;
// Add your code to serialize the changes.
}
private void Title_DoubleClick(object sender, System.EventArgs e)
{
(sender as ChartTitle).Visible = false;
dockControl.Visible = true;
textBox.Focus();
} |
chartTitle.DoubleClick += Title_DoubleClick;
. . .
private void Legend_DoubleClick(object sender, System.EventArgs e)
{
var legend = sender as ChartLegend;
Point p1 = legend.PointToClient(new Point(Control.MousePosition.X, Control.MousePosition.Y));
ChartLegendItem item = legend.GetItemBy(p1);
if (item != null)
{
selectedItem = item;
PopupForm pop = new PopupForm(legend, selectedItem);
pop.ShowDialog();
}
legend.Refresh();
} |
ChartLegend chartlegend;
ChartLegendItem legenditem;
public PopupForm(ChartLegend legend, ChartLegendItem item)
{
InitializeComponent();
chartlegend = legend;
legenditem = item;
textBox1.Text = item.Text;
}
. . .
private void button1_Click(object sender, EventArgs e)
{
legenditem.Text = textBox1.Text;
// Add your code to serialize the changes.
this.Close();
} |
dockControl.Behavior = ChartDockingFlags.Dockable; |
private void Title_DoubleClick(object sender, System.EventArgs e)
{
. . .
(sender as ChartTitle).Orientation = ChartOrientation.Horizontal;
} |
private void Legend_DoubleClick(object sender, System.EventArgs e)
{
var legend = sender as ChartLegend;
ChartLegendItem item = null;
foreach (var legendItem in legend.Items)
{
if(legendItem.Bounds.Contains(new Rectangle((e as MouseEventArgs).X, (e as MouseEventArgs).Y, 1, 1)))
{
item = legendItem;
}
}
if (item != null)
{
selectedItem = item;
PopupForm pop = new PopupForm(legend, selectedItem);
pop.ShowDialog();
}
legend.Refresh();
}
|