How to change bar chart value on each bar to custom value? - c#

Though I have values on the asp graph as attached, what I need is a different value to be shown on each bar.
For example instead of 5 on the bar graph I need to display 50 (instead of the label that displays 5).
What I would like to know is what property like the one below should i use in order to manipulate the label shown on each bar.
Chart1.ChartAreas[0].AxisX.TitleFont = new Font("Times New Roman", 11f);
Thanks in advance.

The value for the label can be set as below:
Chart1.Series["Series1"].Points[counter].Label = "2";

Related

.net c# Livecharts only show one series on tooltip x&y value

I have been trying to create a graph in .net C# with the library: https://v0.lvcharts.com/
I have quite a few different series on my graph and all with different points per x value. As seen below this is the current tooltip on hover.
What i need is to only display the X value: 00:07 & the Series 'Measured Temperature'. I do not want to show any of these other series on my tooltip. If i use the SelectionMode.OnlySender it does not show the X value: 00:07 which is quite important since graphs can be over 24 hours long..... Because otherwise it would be quite tricky to find out at which time you are specifically looking...
Does anyone know how to only show 1 series with Y&X value? Not any other series...
The project is made in WinForms c# .NET
You need to change the IsVisible property in your element of graph collection:
SeriesCollection[i].IsVisible = false;
i - is the index of the element in the collection
If it looked like creating a pre-hidden element:
SeriesCollection = new SeriesCollection
{
new LineSeries
{
Title = "Series 1",
Values = new ChartValues<double> { 4, 6, 5, 2 ,4 }
IsVisible= false; // this one
}
};
Or is your goal to leave all the graphics in place, but only hide all the fields in the ToolTip except the one you hovered over?

Auto Fill combo box is taking full page of size when we press drop down. Need to limit it to top 5 values. without doing query change

I need a little help here with auto fill combo box which will display all the vehicles which are owned by Company.
Please check the screen shot and code and guide me to how to limit the display items in number of 5 so that combo box does not take the full size of page.
I don't want to change anything in query, i want to set it from the code or any available property which can limit it (Note : MaximumDropDownItems is already at 8 still it takes full page). The drop down menu must drop on bottom of the combo box not on upper side of it.
Thanks
Screen Shot
The code for auto fill is as follow :
Dim v As New VehicleMast
dt = v.getvhcl("select Vehicle_NO from MastVehicle")
If com_vhcl_no.InvokeRequired Then
com_vhcl_no.BeginInvoke(New loadVehicleDel(AddressOf loadVehicleSub), cmd, dt)
Else
For Each q In dt.Rows
com_vhcl_no.Items.Add(q("Vehicle_NO"))
Next
With com_vhcl_no
'.DataSource = dt
.DisplayMember = "Vehicle_NO"
.ValueMember = "Vehicle_NO"
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With
End If
You can probably set the height of the ComboBox which can show only a few records and else all the records would be scroll-able
ComboBox1.DropDownList.Height
you can make 5 items visible for all of the items, by doing something like this:
ComboBox1.DropDownList.Height = ComboBox1.Items.Height * 5
or
ComboBox1.MaxDropDownItems = 5;
Set the .MaxDropDownItems property: https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(System.Windows.Forms.ComboBox.MaxDropDownItems);k(System.Windows.Forms.ComboBox);k(VS.Properties);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5)&rd=true

How to add vertical scrollbar to combobox programatically

I am using silverlight and my combobox is like this:
ComboBox cb = new ComboBox();
Suppose it already contains Items which are visible only on clicking the combobox.
I want add a vertical scrollbar(or slider) programatically when it shows its items. Is there any inbuilt property for this in silverlight or do I need to use scrollbar or slider for it?
There is an inbuilt property of ScrollViewer.VerticalScrollbarVisibility. Set its value to Visible.
For more read this
You can try changing the dropdownheight property.
cb.DropDownHeight = cb.ItemHeight * 5;
This is to view only 5 items at a time
You can go to Properties:
And set your specified height here.

Is there any Efficient way to display lots of labels in form?

I have a GUI Program, that creates labels containing names of files according to the search query provided by the user at runtime and displays them. The no of labels displayed can vary considerably based on the user input.
The no can vary between 0 to 2000(approx) . When the no of labels exceed 1000 or so, the time taken for the form in which the labels are contained takes a lot of time to display.
The time taken to display the form completely outweighs the time saved in making a good algorithm(for some cases)!. I am looking for an efficient way so that I can display the form easily in less amount of time. Currently, It takes 1minute 45 seconds to display a form containing 1499 Labels.
Currently , I am doing like this:-
foreach(string Elements in FileList)
{
Label LabelA = new Label() ;
// other code here to modify the appearence of label
LabelA.Show() ;
}
MyForm.Show();
// File List is the List of file names which are to be displayed.
//MyForm is the name of the form in which labels are added at runtime.
There could be at least a couple of techniques:
it's technically impossible that one can look on all of them contemporary, so solution is just devide them into Tabs. So divide them into groups of your application logic.
defered scrolling. So when user scrolls the window, only the data inside them changed (and also corresponding data field)
Just to give an idea, but basically to invite attention to a simple fact that you for sure do need all that controls at once on UI. If these solutions are not ok, change control, so rapresentation of data.
Asyn get result Maybe you can use BackGroundWorker to asynchronously query the result and create the label. The way will give you a well user experience .
Suspend then Resume When you add the label you should use Control.SuspendLayout() and Control.ResumeLayout()
Page the Result Other way you can page for the result.
If you want to use labels with that create labels on program startup and add them a list for instant access to them
// create a list on there
List<Label> lblList = new List<Label>;
public Form1()
{
InitializeComponent();
for(int i = 0 ; i<1500;i++)
{
Label LabelA = new Label() ;
// other code here to modify the appearence of label
LabelA.Show() ;
lblList.Add(LabelA);
}
}
if you do this on a backGroundWorker your program will open fast and you can make a prograss bar for label creation. this will create labels and add them a list. You can access them with their indexes and change their text like that:
int index=0;
foreach(Label o in lblList)
{
o.Text="Text";
index++;//you can use this index if you want to know which label you editing
}
if you create labels on start up this will take some time but when you use them this way will be faster from creating them and values will display instantly.
Sorry for bad english.

Formating the content/properties of a Winform PropertyGrid

(1) Is it possible to format/change the font/color of a particular porperty name in a Winform propertygrid?
In the following example on property name ("Cursor") is red:
(2) Is it possible to change the order of categories or are they fixed alphabetical? in my case I want to have one particular category on top.
You can always set Font for the propertygrid, try this:
propertyGrid1.Font = new System.Drawing.Font("Times New Roman", 20f);
Also you can set PropertySort for it which will mimic its original behavior (like the one in the VS). Check this link

Categories