|
-
August 26th, 2011, 02:07 AM
#1
ListView grouping problem in Large Icon View
Hello,
I'ld like to group items in a large icon view listview (winforms .net 4.0, vs2010). But when I do, I don't see anything! Although I set showgroups to true. Here's my code:
private void ReadData()
{
//Clear nodes
lvEcTopology.Items.Clear();
lvEcTopology.Groups.Clear();
lvEcTopology.ShowGroups = true;
//Read for each master, it's state and slavestate
for (int i = 1; i <= _canMasterArraySize; i++)
{
CanDiagnosticData data = new CanDiagnosticData();
string structName = _canMasterArrayName + "[" + i.ToString() + "]" + _hmiEl6751DataSuffix;
PlcVariable item = new PlcVariable(_plcName, "", PlcVariable.EnumUpdateType.None, 0, PlcType.Tc_BOOL);
object itemValue;
//Read the canstate
item.VariableName = structName + _canStateSuffix;
item.VariableType = _canStateType;
itemValue = item.ReadValueSync();
data.CanState = itemValue != null ? (UInt16)itemValue : (ushort)0;
//Read the RxErrorCounter
item.VariableName = structName + _rxErrCntrSuffix;
item.VariableType = _rxErrCntrType;
itemValue = item.ReadValueSync();
data.RxErrorCounter = itemValue != null ? (byte)itemValue : (byte)0;
//Read the TxErrorCounter
item.VariableName = structName + _txErrCntrSuffix;
item.VariableType = _txErrCntrType;
itemValue = item.ReadValueSync();
data.TxErrorCounter = itemValue != null ? (byte)itemValue : (byte)0;
//Read the NodeswithErrorCounter
item.VariableName = structName + _nodesWithErrSuffix;
item.VariableType = _nodesWithErrType;
itemValue = item.ReadValueSync();
data.NodeswithError = itemValue != null ? (byte)itemValue : (byte)0;
//Add the master
lvEcTopology.Groups.Add("EL6751 - " + i.ToString(), "EL6751 - " + i.ToString());
lvEcTopology.Groups[i-1].Items.Add(new ListViewItem("EL6751 - " + i.ToString(), 2) { Tag = data, ForeColor = (data.CanState == 0 ? Color.Green : Color.Red) });
//Read the NodeStates
item.VariableName = structName + _nodeStatesSuffix;
item.VariableType = _nodeStatesType;
item.IsArray = true;
item.Elements = _canSlaveArraySize;
byte[] nodes = item.ReadValueSync() as byte[];
if (nodes != null)
{
for (int j = 0; j < nodes.Length; j++)
{
if (nodes[j] != 255)
{
CanDiagnosticData slave = new CanDiagnosticData() { NodeState = (CanSlaveState)nodes[j] };
//Add the node
lvEcTopology.Groups[i-1].Items.Add(new ListViewItem("Node - " + (j+1).ToString(), nodes[j] == 2 ? 0 : 1) { Tag = slave, ForeColor = (nodes[j] == 0 ? Color.Green : Color.Red) });
}
}
}
}
}
I really don't know what I'm doing wrong (and yes, it adds 2 groups, each group containing about 10 items). Why is my listview still empty?
Hoping for an answer (really, I'm getting hopeles).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|