Remove Left Margin of Microsoft Chart Control - winforms

How to remove the left margin of a Microsoft Chart Control (Shown as a red rectangle)?
The chart control is docked in the parent form. It seems that this margin is dynamic and depends on the chart width.
I cannot find such an option. Do I need to work with ChartArea location?
This is a .NET C#, WinForms application.

The following code worked for me:
Chart1.ChartAreas[0].Position.X = 0;

If you want to remove all the paddings:
Chart1.ChartAreas[0].Position.X = 0;
Chart1.ChartAreas[0].Position.Width = 100;
Chart1.ChartAreas[0].Position.Height = 100;
Chart1.ChartAreas[0].Position.Y = 0;

Related

add zoom and scroll capability with code behind to SCICHART

Hi I want to add zoom and scroll with code behind to SCICHART
is this possible?
I tried xaml but It did not work. My manager wants it with code behind.
Yes this should be easy, for each modifier in SciChart WPF, you can add it in code behind like this:
var sciChartSurface = new SciChartSurface();
sciChartSurface.XAxis = new NumeriAxis();
sciChartSurface.YAxis = new NumeriAxis();
sciChartSurface.ChartModifiers.Add(new ZoomPanModifier());
sciChartSurface.ChartModifiers.Add(new MouseWheelZoomModifier());
sciChartSurface.ChartModifiers.Add(new ZoomExtentsModifier());
See a full list of the modifiers available in SciChart WPF here

Add Markers in WPF

I need to add markers to my map. Problem: I'm using WPF, not WinForms.
GMapMarker marker = new GMapMarker(new PointLatLng(-25.966688, 32.580528));
gmap.Markers.Add(marker);
Now according to this question the solution is:
marker.Shape = new MarkerShape(....);
Could someone explain to me, how to I initalize this shape?
Thanks!
I resolved the problem with:
marker.Shape = new Ellipse
{
Width = 10,
Height = 10,
Stroke = Brushes.Black,
StrokeThickness = 1.5
};
That's a little black circle.
You have to add a new UserControl - your own, and inside the control put a image you like (for example pin image). Note that all the events (like Click event) must be implement inside a control.
After that you can add the marker like:
GMapMarker marker = new GMapMarker(new PointLatLng(##, ##));
marker.Shape = new PinControl();
gmap.Markers.Add(marker);

WinForms - Dynamically Add Multiline Textboxes to Panel with Horizontal Scrollbars

I have been given a design that I have to reproduce in Winforms. My attempt is shown below...
At the moment I have 5 static labels and 5 static multiline text boxes to hold my lists of "items"...
But, I need to be able to cope with more than 5 columns...
Not being massively experienced in Winforms, what would be the best way to be able to add additional columns with a horizontal scrollbar to enable the user to scroll from left to right?
I was thinking that maybe a panel, with scrollbars set to Auto, and then dynamically add the titles and text boxes at calculated positions?
Is that possible? Is that the best approach?
Any help would be greatly appreciated.
Thanks
Trev
yes, this looks the way to do it...
this code worked as a test...
int number = 0;
int LocationX = 169;
while (number < 10)
{
// create a new multiline text box
TextBox trev = new TextBox();
trev.Size = txtParent1.Size;
trev.Location = new Point() { X = txtParent1.Location.X + LocationX, Y = txtParent1.Location.Y };
trev.Name = number.ToString();
panelSummary.Controls.Add(trev);
number = number + 1;
LocationX += 169;
}
You could create a view that includes a label and the text box and in the main view you could use a TableLayoutPanel, for every view create a new column and add the view inside the column with Dock set to Fill. This way the resizing and the scrolling is handled by the TableLayoutPanel.
TableLayoutPanel

Show icons in WPF application that supports zooming

My WPF application supports zooming. When I show icons on a canvas, and I zoom in, all the shapes, text, etc. are shown correctly, but the icons are shown pixelelated.
What is the correct way to show icons?
I was thinking about building the icons in a vectorial format, and then convert them to XAML?
Is this the correct way?
How should I proceed?
Could you please give an example about how to use it?
You can use ScaleTransform on your icons like.
var st = (ScaleTransform)image.RenderTransform;
double zoom = e.Delta > 0 ? .2 : -.2;
st.ScaleX += zoom;
st.ScaleY += zoom;

Make WinForms control appear on top of all other controls

I have a WinForm, in which I am hiding all borders and the Control Box. Inside the WinForm I have a RECT() (not a WinForms control) the RECT fills the entire WinForm.
I am trying to add a Label to the WinForm, but I want the label to appear on top of the RECT. The Label appears on the WinForm, but never on top of the RECT. I've tried using the following:
/*App Runs - Label does not show up*/
_label.Text = "This is the label";
_label.BackColor = Color.Cornsilk;
_form.Controls.Add(_label);
_form.Controls.SetChildIndex(_label, 0);
/*App Does Not Run*/
_label.Text = "This is the label";
_label.BackColor = Color.Cornsilk;
_form.Controls.SetChildIndex(_label, 0); //trying to set the index before I add the label to the form
_form.Controls.Add(_label);
/*App Runs - Label does not show up*/
_label.Text = "This is the label";
_label.BackColor = Color.Cornsilk;
_label.BringToFront();
_form.Controls.Add(_label);
/*App Runs - Label does not show up*/
_label.Text = "This is the label";
_label.BackColor = Color.Cornsilk;
_form.Controls.Add(_label);
_label.BringToFront();
As you can see, I've tried a lot of different stuff and nothing is working. I have also tried adding the label after the RECT has been added, to no avail. I am having a similar issue with adding a Background Image (though not the question being asked here). Does anyone know of a more forceful way to make the Label appear on top of the RECT?
Also, because of the API and dll's I am using, I cannot use something other than a RECT or WinForms.
You can use BringToFront on the label itself:
_label.BringToFront();
This will bring the label to the front of the Z order on the form, so it should display on top of other form elements.
I have a RECT() (not a WinFrom control) the RECT fills the entire WinForm
A "RECT" isn't a control - it's a definition size and position. Depending on what you're using to display your background, this may not work. If it's painting into the entire form, it could be overwriting your other controls, and "masking" them, no matter what you use for z order. Without more information, it could be difficult to provide guidance, but you'd have to make sure you cause the label to redraw after the "RECT".

Resources