We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to Copy and Paste Multiple columns to multiple rows

Thread ID:

Created:

Updated:

Platform:

Replies:

80642 Apr 20,2009 10:46 AM Apr 28,2009 12:57 PM Windows Forms 5
loading
Tags: GridControl
Ahamed
Asked On April 20, 2009 10:46 AM

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?




Ahamed
Replied On April 22, 2009 02:55 AM

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?






Lingaraj S [Syncfusion]
Replied On April 22, 2009 02:10 PM

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.




Ahamed
Replied On April 24, 2009 09:52 AM

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.






Ahamed
Replied On April 24, 2009 10:06 AM

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.








Lingaraj S [Syncfusion]
Replied On April 28, 2009 12:57 PM

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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;