Greek character are not displayed in winform combobox - winforms

I am working on a winform application, where I have grid with column displaying certain length measurement units. I have defined a column as below.
var unitColumn = new DataGridViewComboBoxColumn {
Name = "UnitColumn",
HeaderText = "UnitColumnHeader",
Width = 80,
DataSource = new[] { "nm", "mm", "μm" },
};
_calibGrid.Columns.Add(unitColumn);
As you can see the second item in the combobox suppose to display μm, but it displays the m. After I choose the item text in the cell displayed correctly. I am quite new to winform development, can any one suggest the fix/solution?

Try - Console.WriteLine("\u00b5");

I came across this same problem (but with some other characters). Don't know why it does this.
It is quite simple to implement the DrawItem event and draw the text correctly. We use a method similar to this:
https://stackoverflow.com/a/857232/417721

Related

How To Highlight a Column in a WinForm StackedColumn Chart

I'd like to highlight a single column in a WinForm StackedColumn Chart. As examples, I'm seeing how to put borders around the individual DataPoints in each Series displayed in the column and put an ArrowAnnotation pointing at one of the DataPoints, but I don’t see a way to highlight the column as a whole. For example, it would be great to have the column expand to say twice the width of the other columns and/or have a different backcolor (including the empty areas above and below the DataPoints). Is it possible to do what I want and, if so, how? C# examples are preferable but not necessary.
Thanks. Steve
You could dim every other column, using BackHatchStyle = ChartHatchStyle.Percent50 and BackSecondaryColor = Color.Black. This will make your chosen column appear brighter/highlighted.
Here's an example:
int highlightColumnIndex = 0; // Set the highlighted column here!
foreach (Series cs in chart1.Series) {
foreach (DataPoint dp in cs.Points) {
dp.BackSecondaryColor = Color.Black;
dp.BackHatchStyle = ChartHatchStyle.Percent50;
}
cs.Points[highlightColumnIndex].BackHatchStyle = ChartHatchStyle.None;
}
Change chart1 to your chart's name, and change highlightColumnIndex to match the index of the column you want to highlight.
Hope this helps :)

Highlight line(s)/characters in WPF

Scenario
I am currently developing an application. Within this application, I have a TextBox/RichTextBox. I have not decided on the control yet. Within this control, there will be a few paragraphs of text.
Problem
I want to be able to highlight a range of lines, or particular characters within that line, using two given numbers. What would the easiest way to do this be?
Use RichTextBox. You can't use TextBox, that is because TextBox has only one style applied to all text.
Use the TextRange.ApplyPropertyValue method. A TextRange is specified by its starting and ending position, which are two TextPointer.
Something like this
var startingPos = RichTextBox1.ContentStart.GetPositionAtOffset(n1, LogicalDirection.Forward);
var endingPos = startingPos.GetPositionAtOffset(n2 - n1, LogicalDirection.Forward);
var textrange = new TextRange(startingPos, endingPos);
textrange.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.DarkRed);
You have to carefully calculate the offsets of the starting and ending positions, taking linebreaks into account.

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

Styling of WPF Chart AreaSerie in program

I need to create area series in WPF chart toolkit in a program, but I do not know how to change a color of serie.
Setting of PathStyle doesn't work even in XAML. According to source files area series should be binded to background color but this doesn't work either.
Thank you for your help.
I had a hard time also figuring out how to change colors. Changing Background colours or ColorPalette didn't seem to do anything. I solved the issue, for the LineSeries, by settings the background with a setter in the style ( the DataPointStyle of the LineSeries, which applies on a DataPoint)
so in vb :
Dim NLS = New LineSeries()
NLS.IndependentValuePath = "Time"
NLS.DependentValuePath = "Quantity"
NLS.Title = " Quantity in function of time"
NLS.ItemsSource = MyItemSource
Dim ThisStyle As New Style(GetType(DataPoint))
ThisStyle.Setters.Add(New Setter(BackgroundProperty, New SolidColorBrush(MyWantedColor)))
NLS.DataPointStyle = ThisStyle
I hope this can help you solve your issue for the Area Series.

Setting Colour on the Editor part of UltraCalendarCombo

Does anyone know how to colour the editor part (where you can type in the date) for the UltraCalendarCombo (winforms one) programmatically (i.e. without using the Style Library files)?
I want to set the background to a different colour whenever the control has focus but can't find any properties or methods to do this.
Thanks
If I understand you correctly, I believe you can do it one of 2 ways...
// Directly via the BackColor property
ultraCalendarCombo1.BackColor = Color.Blue;
// Using an Appearance object
ultraCalendarCombo1.Appearance = new Infragistics.Win.Appearance { BackColor = Color.Blue };
I've actually figure this one out.
Steve's answer colours the editor part and the drop down part as well.
You need to apply other Appearance properties as well.
// This is a copy from Steve's answer
// Directly via the BackColor property
ultraCalendarCombo1.BackColor = Color.Blue;
// Using an Appearance object
ultraCalendarCombo1.Appearance
= new Infragistics.Win.Appearance { BackColor = Color.Blue };
// Now we set the drop down part to a different colour (Let's say white)
ultraCalendarCombo1.DropDownApperance
= new Infragistics.Win.Appearance { BackColor = Color.White };
I believe you can do it by creating .isl (Infragistics Style Library) files but I wasn't quite sure how to swap these in and out programmatically.

Resources