< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Category Archives: GTP.NET FAQ
10819 : When size of TimeItem is small i am unable to increase the time item to the east
Question
when the size of TimeItem is small i am unable to increase the time item at east size, i didn’t get the StopValueResize event.
Whereas it allows me to increase the size at west side but i want to increase its size only to the east side.
If the size of TimeItem is small it should get increased to the east side, Please give me the solution for this problem…
Answer
We agree that iy would be more natural to resize really small items to the east. This is changed in GTP.NET 3.0 (available soon)
10827 : I want to display timeitemtext to the right side of the time item how it is possible?
Question
I want to display timeitemtext to the right side of the time item how it is possible……….?
Answer
You simply set TimeItemTextLayout.OutsideText=true, then the text will be rendered outside of the time item. Use the VertAlign and HorzAlign to control in what quadrant the time item will be drawn (far, far gives lower right corner).
So in your case: right side. Set HorzAlign=StringAlignment.Far and VertAlign=StringAlignment.Center
10772 : Schedule mode headers
Question
Is it possible to set the column name at runtime for the ScheduleMode view? Currently, it looks like it is using the column name of the first column in the grid.
Thanks.
Answer
The column heads in schedule mode are the values from column1 on each row. So just change that cell content to change the header in schedule mode.
10800 : Catching events in inplace edit boxes
Question
I need to know how to fill a combotext (editbox) in the grid (possible without an event ?) and after i need to know how to get a value from that combotextbox after I have selected one item from it by mouse.
Today I only can fill the box with that grid1_OnBeforeEditCell event and I only can retrieve a box value after i have selected one by mouse and additionaly pressed enter.
Answer
You will need to use the event, but you can also hook up event listeners in this event on your combobox. This way you can react to any action taken in the inplace edit box:
private void grid1_OnBeforeEditCell(PlexityHide.GTP.Grid grid, PlexityHide.GTP.BeforeEditEventArgs beforeEdit)
{
if (beforeEdit.Cell.Content is ComboText)
{
(beforeEdit.Cell.Content as ComboText).EditBox.Items.Clear();
(beforeEdit.Cell.Content as ComboText).EditBox.Items.Add("Item 1");
(beforeEdit.Cell.Content as ComboText).EditBox.Items.Add("Item 2");
(beforeEdit.Cell.Content as ComboText).EditBox.Items.Add("Item 3");
(beforeEdit.Cell.Content as ComboText).EditBox.Items.Add("Item 4");
(beforeEdit.Cell.Content as ComboText).EditBox.SelectedIndexChanged += new EventHandler(EditBox_SelectedIndexChanged);
}
else
{
if (beforeEdit.Cell.Content is SingleText)
{
(beforeEdit.Cell.Content as SingleText).EditBox.TextChanged += new EventHandler(EditBox_TextChanged);
}
}
}
void EditBox_SelectedIndexChanged(object sender, EventArgs e)
{
// Tell someone that the index changed
}
void EditBox_TextChanged(object sender, EventArgs e)
{
(sender as TextBox).ForeColor=Color.Green;
}
10767 : Columns for databind
Question
This may be a simple question but having some issues trying to figure it out. How do you connect a DataSource to the gantt chart at runtime and have the columns show up?
What I mean is that the only way I have been able to get something to show up on the control is if I go into the properties of the control at design time and manual add a column the to the collection and map it to the specific field from the datasource. Is there a way to set the data source at runtime and just have the data appear?
Maybe I’m just missing something simple.
Answer
Go like this Gantt.Grid.AutoCreateColumnsFromDataset=true, it should do it
10966 : Is there a way that i can allow users to be able to drag the edges of the fish eye to resize it?
Question
Is there a way that i can allow users to be able to drag the edges of the fish eye to resize it?
Answer
The user interactions with the fisheye is as follows:
ALT-key + click drag : widens the fisheye
SHIFT-key + click drag : moves the fisheye
10783 : How can I sort the Gantt rows?
Question
I have to sort data from a column that is date(initial date) in my Gantt.ASP
How can I sort the Gantt rows?
I have to do this when my gantt already have data, and I want to do this only with code(no click events)
I’m programming in VB.Net
Thanks for all.
Answer
To sort the content on GanttRows you must iterate every layer on each GanttRow and call Sort on the Layer that calls the collectionbase.innerlist.sort method. Implement your own comparer to sort. Do not use if this list is databound, if that is so, you should sort the datasource instead.
To Sort GridNodes you call Gantt.GridStructure.RootNodes.Sort you can send in your own object implementing IComparer to sort on any criteria.
10956 : Custom links
Question
I have created a custom link with the TimeItemLinkDrawStyle.User property but the OnTimeItemLink_SelectionChanged event doesn’t raise and the UserDrawLinkEventArgs.G property is null in the OnUserDrawLink event when i select a custom link. How could i select a custom link?
Can you help me?
Answer
The thing is that user drawn links can have any shape, so we need to find a way to describe that shape so that we can detect a selection.
This is done by a two step process; selection region definition and drawing.
The selection region definition is done in the in the OnUserDrawLink event when the e.BoundingRegion is set. So, to have a selectable straight line link go like this:
< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
void gantt1_OnUserDrawLink(Gantt aGantt, UserDrawLinkEventArgs e)
{
if (e.BoundingRegion!=null)
{
GraphicsPath gp = new GraphicsPath();
gp.AddLine(e.StartPoint, e.TargetPoint);
gp.CloseFigure();
gp.Widen(new Pen(Color.Black,5));
e.BoundingRegion.Union(new Region(gp));
}
else
{
e.G.DrawLine(Pens.Red, e.StartPoint, e.TargetPoint);
}
}
void gantt1_OnTimeItemLink_SelectionChanged(TimeItemLinks aLinks, TimeItemLinkArgs args)
{
if (args.TimeItemLink.TimeItemLinkDrawStyle==TimeItemLinkDrawStyle.User)
MessageBox.Show(“User drawn link selected”);
}
10754 : Replace the DateScaler span text
Question
In the upper left corner of the Gantt chart time-scale there is a couple of dates showing, e.g. Aug 9, 2006 – Aug 9, 2007.
Is there any way to replace those with the system “Data Date” or “Today Date”. If not, is there any way to get ride of those dates?
Thanks
Answer
Implement the event Gantt.DateScaler.OnViewDateInformation and change the value of the argument e.Text to whatever you need.
Or if you want to do something more advanced, like drawing pictures, or multi format string output, just draw it yourself in the Background draw event of the DateScaler and return e.ContinueDraw=false in this event.