How to Copy and Paste Multiple columns to multiple rows

Hello,

I need to use the Ctrl+D functionality of Excel in syncfusion grid. I want to copy single row columns to multiple rows.

Can anybody help on this?




5 Replies

AH Ahamed April 22, 2009 06:55 AM UTC

Is anybody have answer for this?

Thanks & Regards
Ahamed

> Hello,

I need to use the Ctrl+D functionality of Excel in syncfusion grid. I want to copy single row columns to multiple rows.

Can anybody help on this?







LS Lingaraj S Syncfusion Team April 22, 2009 06:10 PM UTC

Hi Ahamed,

The functionality of Ctrl+D in excel can be achieved in GridControl by means of simple workaround handled in CurrentCellKeyDown event.

Please refer to the code below:

this.gridControl1.CurrentCellCloseDropDown += new PopupClosedEventHandler(gridControl1_CurrentCellCloseDropDown);
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
private bool flag = false;
private int row, col;
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
row = this.gridControl1.CurrentCell.RowIndex;
col = this.gridControl1.CurrentCell.ColIndex;
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D)
{
flag = true;
this.gridControl1[row, col].CellType = "ComboBox";
this.gridControl1[row, col].ShowButtons = GridShowButtons.Hide;
StringCollection items = new StringCollection();
for (int i = 1; i < this.gridControl1.RowCount; i++)
{
if (i != row)
{
String s = this.gridControl1[i, col].Text;
if (s != null&&!s.Equals(String.Empty))
{
if (!items.Contains(s))
{
items.Add(s);
}
}
}
}
this.gridControl1[row, col].ChoiceList = items;
this.gridControl1.CurrentCell.ShowDropDown();
}
}
void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
if (flag == true)
{
this.gridControl1[row, col].CellType = "Standard";
flag = false;
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.





AH Ahamed April 24, 2009 01:52 PM UTC

Hi Lingaraj,
Thanks for your reply. If you give it in VB.Net format then it will be helpful for me.

Regards
Ahamed

>Hi Ahamed,

The functionality of Ctrl+D in excel can be achieved in GridControl by means of simple workaround handled in CurrentCellKeyDown event.

Please refer to the code below:

this.gridControl1.CurrentCellCloseDropDown += new PopupClosedEventHandler(gridControl1_CurrentCellCloseDropDown);
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
private bool flag = false;
private int row, col;
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
row = this.gridControl1.CurrentCell.RowIndex;
col = this.gridControl1.CurrentCell.ColIndex;
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D)
{
flag = true;
this.gridControl1[row, col].CellType = "ComboBox";
this.gridControl1[row, col].ShowButtons = GridShowButtons.Hide;
StringCollection items = new StringCollection();
for (int i = 1; i < this.gridControl1.RowCount; i++)
{
if (i != row)
{
String s = this.gridControl1[i, col].Text;
if (s != null&&!s.Equals(String.Empty))
{
if (!items.Contains(s))
{
items.Add(s);
}
}
}
}
this.gridControl1[row, col].ChoiceList = items;
this.gridControl1.CurrentCell.ShowDropDown();
}
}
void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
if (flag == true)
{
this.gridControl1[row, col].CellType = "Standard";
flag = false;
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.







AH Ahamed April 24, 2009 02:06 PM UTC

Hi Lingaraj,

I will tell my exact requiremnt.
In excel we can drag a column and copy the same value to all the columns we select.
Like that i have a row with two or three columns. I want copy that row to 5 or 6 rows.
For this only i need solution.

I hope your solution wil help me to transfer the column values to rows.
I am not sure about the functionality of your solution. Thanks for your help.

Please reply me if you have solution for my exact problem.

Regards
Ahamed
>Hi Lingaraj,
Thanks for your reply. If you give it in VB.Net format then it will be helpful for me.

Regards
Ahamed

>Hi Ahamed,

The functionality of Ctrl+D in excel can be achieved in GridControl by means of simple workaround handled in CurrentCellKeyDown event.

Please refer to the code below:

this.gridControl1.CurrentCellCloseDropDown += new PopupClosedEventHandler(gridControl1_CurrentCellCloseDropDown);
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
private bool flag = false;
private int row, col;
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
row = this.gridControl1.CurrentCell.RowIndex;
col = this.gridControl1.CurrentCell.ColIndex;
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D)
{
flag = true;
this.gridControl1[row, col].CellType = "ComboBox";
this.gridControl1[row, col].ShowButtons = GridShowButtons.Hide;
StringCollection items = new StringCollection();
for (int i = 1; i < this.gridControl1.RowCount; i++)
{
if (i != row)
{
String s = this.gridControl1[i, col].Text;
if (s != null&&!s.Equals(String.Empty))
{
if (!items.Contains(s))
{
items.Add(s);
}
}
}
}
this.gridControl1[row, col].ChoiceList = items;
this.gridControl1.CurrentCell.ShowDropDown();
}
}
void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
if (flag == true)
{
this.gridControl1[row, col].CellType = "Standard";
flag = false;
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.









LS Lingaraj S Syncfusion Team April 28, 2009 04:57 PM UTC

Hi Ahamed.

Thank you for your update.

The GridControl does not have default property for dragging a column to copy . It can be achieved through some workaround, please try by inheriting the MouseControler class to achieve this behavior.

Please refer the sample below:
http://files.syncfusion.com/support/samples/Grid.Windows/forums/F80642/main.htm

Please let me know if you have queries.

Regards,
Lingaraj S.


Loader.
Up arrow icon