private void OnTimeSpanBoxSelectedIndexChanged(NValueChangeEventArgs arg) { NTimeSpanBox timeSpanBox = (NTimeSpanBox)arg.TargetNode; // Log the selected time span TimeSpan timeSpan = timeSpanBox.SelectedTimeSpan; if (timeSpan != TimeSpan.MinValue) { m_EventsLog.LogEvent("Selected time span: " + timeSpan.ToString()); } else { m_EventsLog.LogEvent("Selected time span: none"); } }
protected override NWidget CreateExampleContent() { NTimeSpanBox timeSpanBox = new NTimeSpanBox(); timeSpanBox.HorizontalPlacement = ENHorizontalPlacement.Left; timeSpanBox.VerticalPlacement = ENVerticalPlacement.Top; // Add some time spans to the box timeSpanBox.AddItem(TimeSpan.MinValue); timeSpanBox.AddItem(TimeSpan.Zero); timeSpanBox.AddItem(TimeSpan.FromMinutes(10)); timeSpanBox.AddItem(TimeSpan.FromMinutes(15)); timeSpanBox.AddItem(TimeSpan.FromMinutes(30)); timeSpanBox.AddItem(TimeSpan.FromHours(1)); timeSpanBox.AddItem(TimeSpan.FromHours(1.5)); timeSpanBox.AddItem(TimeSpan.FromHours(2)); timeSpanBox.AddItem(TimeSpan.FromHours(3)); timeSpanBox.AddItem(TimeSpan.FromHours(6)); timeSpanBox.AddItem(TimeSpan.FromHours(8)); timeSpanBox.AddItem(TimeSpan.FromHours(12)); timeSpanBox.AddItem(TimeSpan.FromDays(1)); timeSpanBox.AddItem(TimeSpan.FromDays(1.5)); timeSpanBox.AddItem(TimeSpan.FromDays(2)); // Add the "Custom..." option timeSpanBox.AddCustomItem(); // Select the first item timeSpanBox.SelectedIndex = 0; // Subscribe to the SelectedIndex changed event timeSpanBox.SelectedIndexChanged += OnTimeSpanBoxSelectedIndexChanged; return(timeSpanBox); }