Dear arnostlobel,
thanks for your reply, I will put down the whole script that I am working on it so you will have an idea of what i am talking about, I have done some modifications , what is colored in green is what i modified and what is colored n red needs modification
***************************************************************************************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit.DB;
namespace Lighting_Fixture_Schedule
{
public partial class NewSchedulefrm : System.Windows.Forms.Form
{
#region Identifiers
String _ViewName;
// modified by ramzi al halaby on 22-07-2015 during upgrade to revit 2016
// *************************************************************************
//textNoteTypeSet availableTextNotes;
TextNoteType availableTextNotes;
TextNoteType _HeaderType = null, _CellType = null;
List<LightingFixtureObject> lightingFixtures;
double _ScheduleWidth = 0, _ImageWidth = 0;
public double ScheduleWidth
{
get
{
return _ScheduleWidth;
}
}
public double ImageWidth
{
get
{
return _ImageWidth;
}
}
public TextNoteType HeaderType
{
get
{
return _HeaderType;
}
}
public TextNoteType CellType
{
get
{
return _CellType;
}
}
public String ViewName
{
get
{
return _ViewName;
}
}
#endregion
// modified by ramzi al halaby on 22-07-2015 during upgrade to revit 2016
// *************************************************************************
//public NewSchedulefrm(TextNoteTypeSet iAvaialableTextNotes, List<LightingFixtureObject> iLightingFixtures)
public NewSchedulefrm(TextNoteType iAvaialableTextNotes, List<LightingFixtureObject> iLightingFixtures)
{
InitializeComponent();
availableTextNotes = iAvaialableTextNotes;
lightingFixtures = iLightingFixtures;
}
private void TbleWidthTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
const char Delete = (char)8;
e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete && e.KeyChar != '.';
}
private void ImgWidthTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
const char Delete = (char)8;
e.Handled = !Char.IsDigit(e.KeyChar) && e.KeyChar != Delete && e.KeyChar != '.';
}
private void NewSchedulefrm_Load(object sender, EventArgs e)
{
// added by ramzi on 22-07-2015 while upgrading to revit 2016(needs work still)
// ****************************************************************************
List<TextNoteType> noteTypeList = new List<TextNoteType>();
//List<TextNoteType> noteTypeList
// = new FilteredElementCollector(revitDoc)
// .OfClass(typeof(TextNoteType))
// .Cast<TextNoteType>()
// .ToList();
//load the text styles
//foreach (TextNoteTypeSet tnt in availableTextNotes)
foreach (TextNoteType tnt in noteTypeList)
{
HeaderStyleComboBox.Items.Add(tnt.Name);
CellTypeComboBox.Items.Add(tnt.Name);
}
createDGVColumns();
}
/// <summary>
/// Creates and Sets the columns for the Schedule DataGridView
/// </summary>
private void createDGVColumns()
{
try
{
ScheduleDGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
DataGridViewTextBoxColumn TypeColumn = new DataGridViewTextBoxColumn();
TypeColumn.HeaderText = "Type";
TypeColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
TypeColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn LampColumn = new DataGridViewTextBoxColumn();
LampColumn.HeaderText = "Lamp";
LampColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
LampColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn DescriptionColumn = new DataGridViewTextBoxColumn();
DescriptionColumn.HeaderText = "Description";
DescriptionColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
DescriptionColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn ManufacturerColumn = new DataGridViewTextBoxColumn();
ManufacturerColumn.HeaderText = "Manufacturer";
ManufacturerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
ManufacturerColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn VoltageColumn = new DataGridViewTextBoxColumn();
VoltageColumn.HeaderText = "Voltage";
VoltageColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
VoltageColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn KeynoteColumn = new DataGridViewTextBoxColumn();
KeynoteColumn.HeaderText = "Keynote";
KeynoteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
KeynoteColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
DataGridViewTextBoxColumn ModelColumn = new DataGridViewTextBoxColumn();
ModelColumn.HeaderText = "Model";
ModelColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
ModelColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
ModelColumn.Visible = false;
ScheduleDGV.Columns.AddRange(new DataGridViewColumn[] { TypeColumn, LampColumn, DescriptionColumn, ManufacturerColumn, VoltageColumn, KeynoteColumn, ModelColumn});
ScheduleDGV.AutoGenerateColumns = false;
BindingSource bs = new BindingSource();
bs.DataSource = typeof(LightingFixtureObject);
ScheduleDGV.DataSource = bs;
//Set the properties
TypeColumn.DataPropertyName = "FixtureType";
LampColumn.DataPropertyName = "Lamp";
DescriptionColumn.DataPropertyName = "Description";
ManufacturerColumn.DataPropertyName = "Manufacturer";
VoltageColumn.DataPropertyName = "Voltage";
KeynoteColumn.DataPropertyName = "KeyNote";
ModelColumn.DataPropertyName = "Model";
bs.DataSource = lightingFixtures;
}
catch (Exception x)
{
MessageBox.Show("Error creating Schedule Data\n" + x.Message, "Data Table Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OKButton_Click(object sender, EventArgs e)
{
if (HeaderStyleComboBox.SelectedItem == null)
{
MessageBox.Show("Select Schedule's Header Text Style", "Invalide Header Style", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.DialogResult = DialogResult.None;
}
else if (CellTypeComboBox.SelectedItem == null)
{
MessageBox.Show("Select Schedule's Cells Text Style", "Invalide Cell Style", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.DialogResult = DialogResult.None;
}
else if (NameTextBox.Text == "")
{
MessageBox.Show("Enter a view name", "Invalid View Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.DialogResult = DialogResult.None;
}
else if (TbleWidthTextBox.Text == "")
{
MessageBox.Show("Enter Schedule Width", "Invalid Schedule Width", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.DialogResult = DialogResult.None;
}
else if (ImgWidthTextBox.Text == "")
{
MessageBox.Show("Enter Image Width", "Invalid Image Width", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.DialogResult = DialogResult.None;
}
else
{
//Set Selected Text Notes
setSelectedTextNotes();
_ViewName = NameTextBox.Text;
_ScheduleWidth = Convert.ToDouble(TbleWidthTextBox.Text);
_ImageWidth = Convert.ToDouble(ImgWidthTextBox.Text);
}
}
/// <summary>
/// Set the Selected Text Notes
/// </summary>
private void setSelectedTextNotes()
{
TextNoteTypeSetIterator itor = availableTextNotes.ForwardIterator();
itor.Reset();
while (itor.MoveNext())
{
TextNoteType current = itor.Current as TextNoteType;
if (current.Name.Equals(HeaderStyleComboBox.SelectedItem.ToString()))
{
_HeaderType = current;
}
if (current.Name.Equals(CellTypeComboBox.SelectedItem.ToString()))
{
_CellType = current;
}
}
}
}
}
***************************************************************************************************************************************