TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
try abc
1.4k
306
487.4k
problem selecting cell after datagridviewcell Drop Down
Apr 24 2010 2:05 AM
Hello..
I want to drag n drop Single cell.. such that i can copy the value form one cell to another.. i used following code .. everything works fine but problem is that after dropping cell the new cell where i am dropping value doesn't highlight. and highlight remain on the first cell where i start dragging...
Here is the code.. i try to set current cell .. but still didn't work.
private
void
dataGridView1_MouseDown(
object
sender, MouseEventArgs e)
{
if
(e.Button == MouseButtons.Left)
{
DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
if
(info.RowIndex >= 0 && info.ColumnIndex >= 0)
{
string
text = Convert.ToString(dataGridView1.Rows[info.RowIndex].Cells[info.ColumnIndex].Value);
if
(text !=
null
)
{
dataGridView1.DoDragDrop(text, DragDropEffects.Copy);
}
}
}
}
private
void
dataGridView1_DragEnter(
object
sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
private
void
dataGridView1_DragDrop(
object
sender, DragEventArgs e)
{
if
(e.Data.GetDataPresent(
typeof
(System.String )))
{
DataGridView dgv = (DataGridView)sender;
Point p = dgv.PointToClient(
new
Point(e.X, e.Y));
DataGridView.HitTestInfo info= dgv.HitTest(p.X, p.Y);
if
(info.RowIndex >= 0 && info.ColumnIndex >= 0)
{
dataGridView1[info.ColumnIndex,info.RowIndex].Value = e.Data.GetData(
typeof
(System.String));
dgv.CurrentCell = dataGridView1[info.ColumnIndex, info.RowIndex];
dgv.CurrentCell.Selected =
true
;
}
}
}
Reply
Answers (
2
)
convert JSP code to c#
checkbox list