I'm having a lot of problems reordering the items in the legend of my charts. The thing is I like the order in the chart but I think the order in the legend is wrong and I'd like to reverse that order.
What I tried is:
CType(Me.Content, C1Chart).LegendItems = CType(Me.Content, C1Chart).LegendItems.Reverse()
But it looks like the LegendItems property is readOnly :S
Finally I found the solution of this problem. Some hours lost trying to find a good solution to fix what I think it's a bug .... and at the end I found an easy way.
In the chart legend you can include this property: FlowDirection="RightToLeft"
I succeeded to reverse the legend by reversing only one ChartGroup:
C1Chart1.ChartGroups.ChartGroupsCollection(0).LegendReversed = False
C1Chart1.ChartGroups.ChartGroupsCollection(1).LegendReversed = True
Related
Is it possible to hide a column based on the column name?
I know that if I know the column ID, I can use that like so...
TechSearch.Columns(0).Visible = False
I Want to do something like this...
TechSearch.Columns("Details").Visible = False
I've tried that, and the 'Details' column is still visible.
Thanks
This is perfect
TechSearch.Columns("Details").Visible = False
Please just make sure that the datasource is loaded first before hiding the column.
It's good practice to edit/customize your grid on the DataSourceChanged.
From what I imagined is that you are editing the grid before loading the datasource :).
So this is actually correct...
TechSearch.Columns("Details").Visible = False
There was an exception just before this which was causing it not to hide this column.
Thanks all.
I have a FlowLayoutPanel1 in my form with a bunch of buttons inside it. I wanted to change the way its scroll bar looked so I added a TrackBar1 hoping to make it look better. I can't figure out how to do it.
I tried:
Panel1.AutoScroll.value = TrackBar1.Value
But it gives the error:
'value' is not a member of Boolean
What have I done wrong in this code?
Your code is wrong. Change it to
Panel1.HorizontalScroll.Value = TrackBar1.Value
Here, Panel1.AutoScroll only tells you if it's True or False.
I got it guys. I should've put .VerticalScroll.Value instead of AutoScroll.Value.
Panel1.VerticalScroll.Value = TrackBar1.Value
This worked.
As others have already mentioned, Panel1.AutoScroll is a boolean. You need to use HorizontalScroll.Value or VerticalScroll.Value whichever matches your requirement.
I have a strange problem and it's probably a simple fix, but after much research, I cannot seem to find a solution.
I have a DataGridView on which I'm trying to center the column headings, but the result is a left bias in the centering—almost like an indenting problem. I've seen a few posts on this issue on a site or two, but never a solution. Any thoughts?
Here's the statement I'm currently trying to use:
DataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
The code you've posted is on the right track: you need to set the ColumnHeadersDefaultCellStyle property of your DataGridView control.
However, you need to create a new DataGridViewCellStyle class and assign that to the ColumnHeadersDefaultCellStyle property. You can't modify the Alignment property as your code sample shows unless you have assigned a DataGridViewCellStyle class to this property.
So, for example, the following code achieves perfectly centered column headings in a blank project:
Dim dgvColumnHeaderStyle As New DataGridViewCellStyle()
dgvColumnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
myDataGridView.ColumnHeadersDefaultCellStyle = dgvColumnHeaderStyle
In the future, you may find it easier to do these types of things from the Designer. If you still need to do it yourself through code, you can check the *.Designer.vb file that is created to see how it was done.
EDIT: I just now noticed the slight offset you're referring to in the columns—it does indeed create a little extra padding to the right of each header. It's not a bug, though. There's a much simpler explanation.
Like a ListView, the DataGridView supports sorting by columns. Therefore, each column header reserves enough space to display the sort glyph (usually an arrow) when calculating center justification.
If you want the column headers to be perfectly centered, you'll need to disable sorting. Set the SortMode property for the column to "NonSortable". This should prevent space from being reserved for the sort glyph whenever the column text is center or right justified.
If you want to center or use any other alignment style of the Column Header text you can use this
dgvResults.Columns("ColumnName").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
Am I going mad/blind? Probably a combination of the two.
How does one go about removing the data labels from a pie chart with the new chart control in .net 4?
I can get these to display as tooltips absolutely fine, but ultiamtely I'd like the labels not to be present as it looks rather busy.
I've searched previous answers and seen code behind resolutions but surely there must be some sort of code infront option to turn these labels off?
Apologies for being thick/blind.
EstadoPie2.Series("EstadoSummarySeries")("PieLabelStyle") = "Disabled"
This worked for me.
for (var i = 0; i < Chart.Series.Count; i++)
{
Chart.Series[i]["PieLabelStyle"] = "Disabled";
}
when DataGridView has a combobox column, how can I get the text it displays as oppose to the value it represents? When I do DGV.Item("cbo",i).Value I get the value but it won't take DGV.Item("cbo",i).Text. I trying Ctype(DGV.Item("cbo",i),ComboBox).Text and this does not work either.
Try
DGV.item("cbo",i).DisplayMember
Umm are you talking about Win Forms?
If so, Value is the property you want, and is what is to be displayed on the screen and held behind the scenes.
If you want something different not shown to the user, I've often used the property Tag for that.
I found this, and the answers didn't work for me. In case someone else finds this, here is what I did.
dgv.rows(i).Cells(cboname.index).EditedFormattedValue
Hope if someone finds this through Google it will help them.
Dim dgvcmbcell As DataGridViewComboBoxCell = DgvItemsUnits.Item("UNIT_SER", 0)
Dim SelectedText As String = dgvcmbcell.EditedFormattedValue.ToString()