| Author: Note: Last updated Oct 29th, 07 to v1.1. See changelog.
Directions: To add DHTML Window widget to your page, just download "dhtmlwindow.zip":
Inside demo.htm, you'll find the 4 DHTML window demos shown For your InformationThere's very little editing required to the script files themselves. Near the top Stage 2: You're now ready to open a DHTML window on your page. The function attributes, [recalonload]) Here are two examples, one opening a DHTML window automatically as the page loads, var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal") </script> <a href="#" onClick="ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'external.htm', 'Ajax Win Title', 'width=650px,height=400px,left=300px,top=100px,resize=0,scrolling=1'); return false">Create/ Open Ajax Window</a> Notice the "recal" parameter at the end that's defined in the
Stage 3: Learning how to open a window is just half the fun. Once it's open, var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal") //OR <a href="#" onClick="yahoowin=dhtmlwindow.open('yahoo', 'iframe', 'http://yahoo.com', 'Yahoo', 'width=500px,height=300px,center=1'); return false">Show Yahoo</a> It is via this unique variable for each window created that enables you to continue
As a reminder, these methods are called on top of the window's unique variable name on --> <script type="text/javascript"> var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal") </script> <a href="#" onClick="googlewin.load('iframe', 'http://cssdrive.com', 'CSS Drive'); return false">Load new site into window</a> <a href="#" onClick="googlewin.moveTo('middle', 'middle'); return false">Center Window</a> <a href="#" onClick="googlewin.hide(); return false">Hide Window</a> <a href="#" onClick="googlewin.close(); return false">Close Window</a> create/open a DHTML window plus manipulate it further when a link is clicked on --> <script type="text/javascript"> function openmypage(){ //Define arbitrary function to run desired DHTML Window widget codes ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "volunteer.htm", "Ajax Window Title", "width=650px,height=400px,left=300px,top=100px,resize=1,scrolling=1") ajaxwin.onclose=function(){ //Run custom code when window is about to be closed return window.confirm("Close this window?") } } </script> <a href="#" onClick="openmypage(); return false">Open the page "volunteer.htm" in a DHTML window</a> All this may seem a little daunting, but it really isn't. We have a habit of being Move over popup windows, there's a new kid in town! |
Tuesday, March 25, 2008
DHTML Window Widget
Friday, November 9, 2007
Drag and Drop Functionality
Drag and Drop Functionality
Download DragDropSample.zip - 36.1 KB http://www.codeproject.com/useritems/Drag_Drop_from_GridView/DragDropSample.zip
Original Article by Mr. Nauman Bhatti
Introduction
In the article, we will learn how to drag a cell's text from a DataGridView and drop it to Textbox or RichTextBox control

Using the code
In the drag operation of a text from the DataGridView cell, the following
events participate:
dataGridView1_MouseDown
This event occurs when the mouse pointer is over the control and a mouse button
is pressed. We use this event to capture the cell's text which is being dragged
from the DataGridView. The following line of code accomplishes this:
if (e.Button == MouseButtons.Left)
{
DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
if (info.RowIndex >= 0)
{
if (info.RowIndex >= 0 && info.ColumnIndex >= 0)
{
string text = (String)dataGridView1.Rows[info.RowIndex].Cells info.ColumnIndex].Value;
if (text != null)
dataGridView1.DoDragDrop(text, DragDropEffects.Copy);
}
}
}
DataGridView.HitTestInfo, Contains information, such as the row and column indexes, about a specific coordinate pair in the DataGridView control. This class cannot be inherited.
This is all that you have to write on DataGridView's events.
Drop a text on TextBox
textBox1_DragDrop
This event occurs when the mouse pointer is on the textbox control and mouse button is released. you have to typecast the data from the DragEventArgs to assign it to the text property of the textbox.
textBox1_DragEnter
This event occurs when the mouse pointer is dragged and it enters in the
textbox. Here you have to specify the effects of the drap-drop opertaion
Other then this you also have to set the "AllowDrop" property of the textbox to
"true".
Drop a text in RichTextBox
To drop a text in the RichTextBox you only have to set it's "EnableAutoDragDrop"
property to "true".
Download DragDropSample.zip - 36.1 KB http://www.codeproject.com/useritems/Drag_Drop_from_GridView/DragDropSample.zip
Original Article by Mr. Nauman Bhatti
Introduction
In the article, we will learn how to drag a cell's text from a DataGridView and drop it to Textbox or RichTextBox control

Using the code
In the drag operation of a text from the DataGridView cell, the following
events participate:
dataGridView1_MouseDown
This event occurs when the mouse pointer is over the control and a mouse button
is pressed. We use this event to capture the cell's text which is being dragged
from the DataGridView. The following line of code accomplishes this:
{
DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
if (info.RowIndex >= 0)
{
if (info.RowIndex >= 0 && info.ColumnIndex >= 0)
{
string text = (String)dataGridView1.Rows[info.RowIndex].Cells info.ColumnIndex].Value;
if (text != null)
dataGridView1.DoDragDrop(text, DragDropEffects.Copy);
}
}
}
DataGridView.HitTestInfo, Contains information, such as the row and column indexes, about a specific coordinate pair in the DataGridView control. This class cannot be inherited.
This is all that you have to write on DataGridView's events.
Drop a text on TextBox
textBox1_DragDrop
This event occurs when the mouse pointer is on the textbox control and mouse button is released. you have to typecast the data from the DragEventArgs to assign it to the text property of the textbox.
{
if (e.Data.GetDataPresent(typeof(System.String)))
{
textBox1.Text = (System.String)e.Data.GetData(typeof(System.String));
}
}
textBox1_DragEnter
This event occurs when the mouse pointer is dragged and it enters in the
textbox. Here you have to specify the effects of the drap-drop opertaion
{
e.Effect = DragDropEffects.Copy;
}
Other then this you also have to set the "AllowDrop" property of the textbox to
"true".
Drop a text in RichTextBox
To drop a text in the RichTextBox you only have to set it's "EnableAutoDragDrop"
property to "true".
Subscribe to:
Posts (Atom)