Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Multicolored Time entries on Gant chart
posted

Hello,

what do I have to do to get the following on a Windows forms Gantt chart

Lets say task 1 has 10 Time Entries

Entry one of task 1 is Color Blue, entry 2 is color red etc...

I tried this on creating the timeentry, but it draws all time entries in the same color.

                        DataRow[] drs = dr.GetChildRows("Machine Data");
                        int lastid = -1;
                        GanttItem task1 = series.Items.Add(dr["Machine"].ToString());
                        task1.PE.Fill = Color.Black;
                        //bool first = true;
                        foreach (DataRow drChild in drs)
                        {
                                DateTime start = DateTime.Parse(drChild["StartTime"].ToString());
                                DateTime end    = DateTime.Parse(drChild["EndTime"].ToString());
                                GanttTimeEntry te = new GanttTimeEntry(start, end, int.Parse(drChild["ID"].ToString()), lastid, "", 100);
                                te.PE.ElementType = PaintElementType.SolidFill;
                                string text = drChild["Text"].ToString();
                                if (text.Contains("waiting for data"))
                                    te.PE.Fill = Color.DarkMagenta;
                                else if (text.Contains("waiting for cylinder"))
                                    te.PE.Fill = Color.Magenta;
                                else if (text.Contains("process running"))
                                    te.PE.Fill = Color.Green;
                                else if (text.Contains("process finish"))
                                    te.PE.Fill = Color.Honeydew;
                                else if (text.Contains("machine inspection"))
                                    te.PE.Fill = Color.Orange;
                                else if (text.Contains("error"))
                                    te.PE.Fill = Color.Red;
                                te.Owner = text;
                                task1.Times.Add(te);
                            }

Can anyone supply a small example ?

Many Thanks

Parents
No Data
Reply
  • 405
    Offline posted

    It works. The code above is okay.

    for some reasons it did not draw correctly

Children