Can someone assist me in using infragistics object to launch an excel file. Meaning opening the the excel file.
What I am trying to do accomplish is opening up an excel template , letting the user save some values in the excel file, once the user close the excel file. The application will detect that the file is close, once the file is closed. the thread or application continues to process the values in the excel file. This is what the customer wants, I was thinking that it was a little weird and not safe.
What is if we use a listbox or ultragrid that has one column that will allow the user to copy and paste values into one column, and then when I close the listbox or form that contains the list box i process some values or do something.
Is this possible to copy paste multiple values in one column or even multiple columns, is so can you give me an example or property to set to allow me to copy and paste values into a column.
Hello KeithDudley,
I am still following this forum thread.
Please feel free to let us know if you have any other questions with this matter here or through your case.
Yes after getting access to the clipboard I need to determine how manys are as far as rows goes, that way I know how many rows to provide for the grid or ultra grid.
For example if the user open an excel sheet to copy and paste 100 rows, I want to be able to find the the number of rows that were copied and the provide the grid a 100 rows, also how to give the grid a 100 rows, if you know what i mean.
I do understand what is your requirement, the I would like to know how many columns are you going to have in your UltraGrid. It would be important for populating the UltraGrid. This also includes creating dynamically your DataTable for example and then binding it to your UltraGrid, or just updating the underlying DataSource of the UltraGrid , from the clipboard, if you do not know the number of the rows in advance.
If you have any other questions please feel free to ask us.
I am getting ready to chat with you on live chat, its better that way,
but I am only going to provide the user one column only, they normally go to an excel template and copy a list values in column A, so I am providing the functionality in a ultra grid with one column so they dont have to depend on the excel sheet. Then once I copied and paste the values into the grid, then close the grid I want to used those values in the grid to do something. But its one column.
I have created small sample for you which provides the desired functionality. I am handling the Error event of the UltraGrid and there if the error is about pasting more rows than the UltraGrid actually has, than I am creating those rows in the DataTable that is bound to the UltraGrid as a DataSource.
Also the sample will work only for mentioned scenario, when you are pasting values copied from a single column in excel to you UltraGrid. If you need to extend this functionality please feel free to do so with the provided code.
Please find the code snippet below and let me know if this is what you are looking for:
public partial class Form1 : Form { DataTable dt; public Form1() { InitializeComponent(); dt = new DataTable(); dt.Columns.Add("Str1", typeof(string)); dt.Rows.Add(); ultraGrid1.DataSource = dt.DefaultView; } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.CellClickAction = CellClickAction.CellSelect; e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All; } private void ultraGrid1_Error(object sender, ErrorEventArgs e) { if (e.ErrorType == ErrorType.MultiCellOperation && e.MultiCellOperationErrorInfo.Operation == MultiCellOperation.Paste) { e.Cancel = true; dt.Rows.RemoveAt(0); string[] rows = ((string)Clipboard.GetDataObject().GetData(typeof(string))).Split(new char[] { '\n' }); foreach (string row in rows) { if (row != String.Empty) { string[] cells = row.Split(new char[] { '\r' }); foreach (String cel in cells) { if(cel != String.Empty) dt.Rows.Add(cel); } } } } } }
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.CellClickAction = CellClickAction.CellSelect; e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All; }
private void ultraGrid1_Error(object sender, ErrorEventArgs e) { if (e.ErrorType == ErrorType.MultiCellOperation && e.MultiCellOperationErrorInfo.Operation == MultiCellOperation.Paste) { e.Cancel = true; dt.Rows.RemoveAt(0); string[] rows = ((string)Clipboard.GetDataObject().GetData(typeof(string))).Split(new char[] { '\n' }); foreach (string row in rows) { if (row != String.Empty) { string[] cells = row.Split(new char[] { '\r' }); foreach (String cel in cells) { if(cel != String.Empty) dt.Rows.Add(cel); } } } } } }
Please use the following code inside the InitializeLayout event of the UltraGrid:
e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All; e.Layout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom; e.Layout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;