I have a listView which I add a number of buttons to in a for loop. However the listView isn't scrollable even if I set it to be scrollable. I'm not sure why this is happening. I'm simply adding a button every time I enter the for loop however once there is too many buttons to view on the listview no scroll bar appears. My code is as follows.
ListViewTemplates.HeaderStyle = ColumnHeaderStyle.None
For i As Integer = 1 To level3Cat.Count
counter = i Mod 2
If counter = 0 Then
Dim picture As Button = New Button()
picture.Location = New System.Drawing.Point(165, topForNextControl)
picture.Size = New System.Drawing.Size(90, layoutTemplateHeight)
picture.TabStop = False
picture.BackgroundImageLayout = BackgroundImageLayout.Stretch
picture.BackgroundImage = My.Resources.XButton
ListViewTemplates.Controls.Add(picture)
topForNextControl += layoutTemplateHeight + HeighScaleFactor
Else
Dim picture As Button = New Button()
picture.Location = New System.Drawing.Point(35, topForNextControl)
picture.Size = New System.Drawing.Size(90, layoutTemplateHeight)
picture.TabStop = False
picture.BackgroundImageLayout = BackgroundImageLayout.Stretch
picture.BackgroundImage = My.Resources.XButton
ListViewTemplates.Controls.Add(picture)
End If
ListViewTemplates.Scrollable = True
ListViewTemplates.View = View.Details
counter += 1
Next
Related
This question is related to this one: Codename One - container.setScrollVisible(true) in the center of a BorderLayout
In the following example of code the setScrollVisible(true) works correctly when the user expands the Accordion (that occupies more space that the height of the screen) and does the scrolling:
Form hi = new Form("Hi World", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
Container body = new Container(BoxLayout.y());
for (int i = 0; i < 100; i++) {
body.add(new Label("Label " + i));
}
Accordion accordion = new Accordion();
accordion.addContent("Tap to expand", body);
Container center = new Container(BoxLayout.y());
center.add(accordion);
center.setScrollableY(true);
center.setScrollVisible(true);
center.getAllStyles().setPaddingUnit(Style.UNIT_TYPE_DIPS);
center.getAllStyles().setPadding(2, 2, 2, 2);
hi.add(BorderLayout.CENTER, center);
hi.show();
But in this other example of code, the setScrollVisible(true) doesn't work when the user expands all the Accordions (that occupy more space that the height of the screen) and does the scrolling:
Form hi = new Form("Hi World", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
// Warning: you need to set the theme property "ComponentGroupBool" to true
Button button1 = new Button("Button 1", "ButtonMenuCategories");
CheckBox button11 = CheckBox.createToggle("Button 1.1");
CheckBox button12 = CheckBox.createToggle("Button 1.2");
Button button13 = new Button("Button 1.3", "ButtonMenuCategories");
CheckBox button131 = CheckBox.createToggle("Button 1.3.1");
CheckBox button132 = CheckBox.createToggle("Button 1.3.2");
CheckBox button133 = CheckBox.createToggle("Button 1.3.3");
CheckBox button14 = CheckBox.createToggle("Button 1.4");
Button button2 = new Button("Button 2", "ButtonMenuCategories");
Button button3 = new Button("Button 3", "ButtonMenuCategories");
Button button4 = new Button("Button 4", "ButtonMenuCategories");
Button button5 = new Button("Button 5", "ButtonMenuCategories");
Accordion accordion13 = new Accordion();
ComponentGroup cmpGroup1 = ComponentGroup.enclose(button131, button132, button133);
cmpGroup1.setScrollable(false);
accordion13.addContent(button13, FlowLayout.encloseCenter(cmpGroup1));
Accordion accordion1 = new Accordion();
ComponentGroup cmpGroup2 = ComponentGroup.enclose(button11, button12, accordion13, button14);
cmpGroup2.setScrollable(false);
accordion1.addContent(button1, FlowLayout.encloseCenter(cmpGroup2));
Accordion accordion2 = new Accordion();
accordion2.addContent(button2, new Label("Hello"));
Accordion accordion3 = new Accordion();
accordion3.addContent(button3, new Label("Hello"));
Accordion accordion4 = new Accordion();
accordion4.addContent(button4, new Label("Hello"));
Accordion accordion5 = new Accordion();
accordion5.addContent(button5, new Label("Hello"));
ComponentGroup cmpGroup = ComponentGroup.enclose(accordion1, accordion2, accordion3, accordion4, accordion5);
Container menu = FlowLayout.encloseCenter(cmpGroup);
accordion13.setScrollable(false);
accordion1.setScrollable(false);
accordion2.setScrollable(false);
accordion3.setScrollable(false);
accordion4.setScrollable(false);
accordion5.setScrollable(false);
cmpGroup.setScrollable(false);
menu.setScrollableY(true);
menu.setScrollVisible(true);
hi.add(BorderLayout.CENTER, menu);
hi.show();
What's wrong in the second example of code?
currently I can display pushpins onto my Bing Maps but I would simply like to remove them when another button is pressed, in this case I would be calling it BTNReset. This is just to make the maps a little more tidy when it becomes clustered so the user can remove all uneccessary pushpins.
Private Sub Berwickshire() Handles BTNCounty.Click
If TXTCounty.Text = "Berwickshire" Then
Dim CountyLocation(20) As Microsoft.Maps.MapControl.WPF.Location
CountyLocation(0) = New Microsoft.Maps.MapControl.WPF.Location(55.705617, -2.4676497)
CountyLocation(1) = New Microsoft.Maps.MapControl.WPF.Location(55.780619, -2.3413039)
CountyLocation(2) = New Microsoft.Maps.MapControl.WPF.Location(55.720304, -2.2638738)
CountyLocation(3) = New Microsoft.Maps.MapControl.WPF.Location(55.746443, -2.2271899)
CountyLocation(4) = New Microsoft.Maps.MapControl.WPF.Location(55.808939, -2.4924539)
CountyLocation(5) = New Microsoft.Maps.MapControl.WPF.Location(55.882232, -2.3064212)
CountyLocation(6) = New Microsoft.Maps.MapControl.WPF.Location(55.852663, -2.3889276)
CountyLocation(7) = New Microsoft.Maps.MapControl.WPF.Location(55.802325, -2.2096172)
CountyLocation(8) = New Microsoft.Maps.MapControl.WPF.Location(55.651853, -2.252035)
CountyLocation(9) = New Microsoft.Maps.MapControl.WPF.Location(55.690431, -2.3361588)
CountyLocation(10) = New Microsoft.Maps.MapControl.WPF.Location(55.645024, -2.3311619)
CountyLocation(11) = New Microsoft.Maps.MapControl.WPF.Location(55.932739, -2.3614317)
CountyLocation(12) = New Microsoft.Maps.MapControl.WPF.Location(55.870455, -2.0969097)
CountyLocation(13) = New Microsoft.Maps.MapControl.WPF.Location(55.852035, -2.1896638)
CountyLocation(14) = New Microsoft.Maps.MapControl.WPF.Location(55.887334, -2.1601164)
CountyLocation(15) = New Microsoft.Maps.MapControl.WPF.Location(55.841716, -2.1222754)
CountyLocation(16) = New Microsoft.Maps.MapControl.WPF.Location(55.771675, -2.803132)
CountyLocation(17) = New Microsoft.Maps.MapControl.WPF.Location(55.719837, -2.750872)
CountyLocation(18) = New Microsoft.Maps.MapControl.WPF.Location(55.680163, -2.5615687)
CountyLocation(19) = New Microsoft.Maps.MapControl.WPF.Location(55.741492, -2.5838242)
CountyLocation(20) = New Microsoft.Maps.MapControl.WPF.Location(55.637369, -2.6798897)
Dim names = New String() {
"Greenlaw",
"Duns",
"Swinton",
"Whitsome",
"Longformacus",
"Grantshouse",
"Abbey St Bathans",
"Chirnside",
"Coldstream",
"Leitholm",
"Birgham",
"Cockburnspath",
"Eyemouth",
"Reston",
"Coldingham",
"Ayton",
"Oxton",
"Lauder",
"Gordon",
"Westruther",
"Earlston"}
For index = 0 To CountyLocation.Length - 1
Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
Dim CoordinateTip = New System.Windows.Controls.ToolTip()
CoordinateTip.Content = names(index)
Pin.Location = CountyLocation(index)
Pin.ToolTip = CoordinateTip
BingMap.Children.Add(Pin)
Next
End If
End Sub
You can do BingMap.Children.Clear() to remove all data on the map.
I'm trying to select a node in TreeListLookupEdit.
var fn = treeListLookupEdit1.FindNodeByKeyID(NodeId);
treeListLookupEdit1.Properties.TreeList.FocusedNode = fn;
My TreeListLookupEdit is already filled with the data (from an EF datasource), I need to focus the desired row and see this value in both treeListLookUpEdit1.Text (when it is in a closed state) and when I open a popup window too.
But nothing happens, it does not selects the node.
I've also tried this (Where "treeNodes" is the actual TreeList inside the TreeListLookupEdit):
treeNodes.FocusedNode = fn;
But, when I run this piece of code, it works:
treeListLookupEdit1.ShowPopup();
treeListLookupEdit1.Properties.TreeList.FocusedNode = fn;
treeListLookupEdit1.ClosePopup();
So, how to avoid using the ShowPopup?
Update
It seems, you should set EditValue
treeListLookupEdit1.EditValue = NodeId
You need to set up TreeListLookUpEdit.Properties.DisplayMember property and TreeListLookUpEdit.Properties.ValueMember property.
Set the TreeListLookUpEdit.Properties.DisplayMember property to the column that you want to display in your TreeListLookupEdit and TreeListLookUpEdit.Properties.ValueMember to ID column and use TreeListLookUpEdit.EditValue to focus node.
After that you can do something like this:
treeListLookupEdit1.EditValue = fn.GetValue("YourIDColumn");
Here is example with DataTable as data source:
var dataTable = new DataTable();
dataTable.Columns.Add("ID", typeof(int));
dataTable.Columns.Add("Parent_ID", typeof(int));
dataTable.Columns.Add("Name", typeof(string));
dataTable.Rows.Add(1, null, "1");
dataTable.Rows.Add(2, null, "2");
dataTable.Rows.Add(3, null, "3");
dataTable.Rows.Add(4, 1, "1.1");
dataTable.Rows.Add(5, 1, "1.2");
dataTable.Rows.Add(6, 3, "3.1");
dataTable.Rows.Add(7, 3, "3.2");
dataTable.Rows.Add(8, 5, "1.2.1");
var treeListLookUpEdit = new TreeListLookUpEdit();
var properties = treeListLookUpEdit.Properties;
properties.DataSource = dataTable;
properties.DisplayMember = "Name";
properties.ValueMember = "ID";
var treeList = properties.TreeList;
treeList.KeyFieldName = "ID";
treeList.ParentFieldName = "Parent_ID";
treeList.RootValue = DBNull.Value;
Controls.Add(treeListLookUpEdit);
treeListLookUpEdit.Size = treeListLookUpEdit.CalcBestSize();
If you set EditValue property of this treeListLookUpEdit object for example to 5 then you will see "1.2" text in control and node with such text will be focused:
treeListLookUpEdit.EditValue = 5;
I'm creating a part of my window in code. For a combobox I do this:
ObservableCollection<ParamClassOption> options = new ObservableCollection<ParamClassOption>(
context.ParamClassOptions.Where(x => x.IDParamClass == val.CompTypeParam.IDParamClass));
ComboBox combobox = new ComboBox();
combobox.Name = "combobox" + val.CompTypeParam.ParameterName.Replace(" ", "");
combobox.ItemsSource = options;
combobox.SelectedValuePath = "IDParamClass";
combobox.DisplayMemberPath = "OptionName";
if (val.ParamClassOption != null)
{
combobox.SelectedValue = val.ParamClassOption.IDParamClassOption;
}
layoutitem.Content = combobox;
I'm able to select an item from the list and save it to the database. The problem that I have is to show the saved value again upon retrieving the values back from the database. Any idea why it's not showing? val.ParamClassOption.IDParamClassOption in the second to last line above has the correct value when the record is retrieved to be displayed.
i think you forgot to bind your selected value
var binding = new Binding {Path = new PropertyPath("IDParamClassOption"), Mode = BindingMode.TwoWay, Source = val.ParamClassOption};
combobox.SetBinding(ComboBox.SelectedValueProperty, binding);
hope this helps
Thanks for the help. I ended up using a completely different approach by adding the items to the combo-box one by one. I then set the selected item to previously added value (using the Text property). Here is what my code looks like now:
if (controlType == "Combobox")
{
ComboBox combobox = new ComboBox();
combobox.Name = "combobox" + val.CompTypeParam.ParameterName.Replace(" ", "");
ObservableCollection<ParamClassOption> options = new ObservableCollection<ParamClassOption>(
context.ParamClassOptions.Where(x => x.IDParamClass == val.CompTypeParam.IDParamClass));
combobox.Items.Clear();
foreach (ParamClassOption option in options)
{
ComboBoxItem item = new ComboBoxItem();
item.Content = option.OptionName;
combobox.Items.Add(item);
}
combobox.Text = val.ParamClassOption.OptionName;
layoutitem.Content = combobox;
}
Later when reading the value from the combobox to save to the database I did this:
ObservableCollection<ParamClassOption> option = new ObservableCollection<ParamClassOption>(
context.ParamClassOptions.Where(o => o.IDParamClass == value.CompTypeParam.IDParamClass).Where(o => o.OptionName == combobox.Text));
value.IDParamClassOption = option[0].IDParamClassOption;
I am using Nevron Charting Control ver.11.1.17.12 in application. I am facing problem in drawing the chart correct with the DateTimeScaleConfigurator. Here are following problem:
Series Bar overlapping each other if series count increases.
Series getting out of the Axis lines.
X Axis Scale automatically add previous year December and next year Jan in the scale which cause the chart to have blank area in case of Surface Chart.
//code snippet to draw Bar Chart Series
NBarSeries bar = new NBarSeries();
bar.UniqueId = new Guid(outputVariable.UniqueId);
bar.Name = outputVariable.LegendText;
chart.Series.Add(bar);
bar.HasBottomEdge = false;
bar.MultiBarMode = chart.Series.Count == 1 ? MultiBarMode.Series : MultiBarMode.Clustered;
// bar.InflateMargins = true;
bar.UseZValues = false;
indexOfSeries = chart.Series.IndexOf(bar);
ConfigureChartSeries(bar, indexOfSeries, outputVariable);
SetSeriesAxisInformation(bar, outputVariable.Unit);
bar.UseXValues = true;
foreach (DataRow row in seriesDataTable.Rows)
{
bar.XValues.Add(Convert.ToDateTime(row["TimeStamp"]).ToOADate());
}
code snippet to Add Surface Chart Series
chart.Enable3D = true;
chart.BoundsMode = BoundsMode.Stretch;
(chart as NCartesianChart).Fit3DAxisContent = true;
chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop);
chart.LightModel.EnableLighting = false;
chart.Wall(ChartWallType.Back).Visible = false;
chart.Wall(ChartWallType.Left).Visible = false;
chart.Wall(ChartWallType.Floor).Visible = false;
// setup Y axis
chart.Axis(StandardAxis.PrimaryY).Visible = false;
// setup Z axis
NAxis axisZ = chart.Axis(StandardAxis.Depth);
axisZ.Anchor = new NDockAxisAnchor(AxisDockZone.TopLeft);
NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator();
scaleZ.InnerMajorTickStyle.Visible = false;
scaleZ.MajorGridStyle.ShowAtWalls = new ChartWallType[0];
scaleZ.RoundToTickMin = false;
scaleZ.RoundToTickMax = false;
axisZ.ScaleConfigurator = scaleZ;
axisZ.Visible = true;
// add a surface series
NGridSurfaceSeries surface = new NGridSurfaceSeries();
surface.UniqueId = new Guid(outputVariable.UniqueId);
surface.Name = outputVariable.LegendText;
chart.Series.Add(surface);
surface.Legend.Mode = SeriesLegendMode.SeriesLogic;
surface.ValueFormatter = new NNumericValueFormatter("0.0");
surface.FillMode = SurfaceFillMode.Zone;
surface.FrameMode = SurfaceFrameMode.Contour;
surface.ShadingMode = ShadingMode.Flat;
surface.DrawFlat = true;
// Already set this property to false and working in other chart.
surface.InflateMargins = false;
surface.FrameColorMode = SurfaceFrameColorMode.Zone;
surface.SmoothPalette = true;
surface.Legend.Format = "<zone_value>";
surface.FillMode = SurfaceFillMode.Zone;
surface.FrameMode = SurfaceFrameMode.Contour;
CreateSurfaceSeries(outputVariable, surface);
chartControl.Refresh();
And the ScaleConfigurator configuration
chartPrimaryXAxis = chart.Axis(StandardAxis.PrimaryX);
// X Axis Configuration
dateTimeScale = new NDateTimeScaleConfigurator();
dateTimeScale.Title.Text = string.Empty;
dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90);
dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft;
dateTimeScale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Times New Roman", 6);
dateTimeScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale };
chartPrimaryXAxis.ScaleConfigurator = dateTimeScale;
chartPrimaryXAxis.ScrollBar.ResetButton.Visible = true;
chartPrimaryXAxis.ScrollBar.ShowSliders = true;
dateTimeScale.EnableUnitSensitiveFormatting = true;
Here is the generated output:
Any idea regarding this problem will be deeply appreciated.
Thanks in advance.
Series Bar overlapping each other if series count increases.
&
Series bar getting out of the Axis lines.
Answer: When you are using categorial data then use NOrdinalScaleConfigurator rather than NDateTimeScaleConfigurator. It will not solve the problem and put the series bar in the center of the scale and auto resize them according to the chart size also.
X Axis Scale automatically add previous year December and next year
Jan in the scale which cause the chart to have blank area in case of
Surface Chart.
Answer:
Set the following properties of the DateTimeScaleConfigurator to false to avoid such behavior.
dateTimeScale.RoundToTickMax = false;
dateTimeScale.RoundToTickMin = false;