Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Soul #1
Q: Scroll to a Row?
Hi,
I have DataGrid on a C# Windows Application. Can I know how can I scroll to
a particular row in the DataGrid?
Thank you.
--
Soul
Soul Guest
-
I want a scroll bar. I might die.
So I've been reading through the help files and my "Flash MX2004 for Dummies" for a while now... still haven't quite got it. I have a staticframe... -
Scroll 2 text by one scroll bar?
Is there anyway to scroll 2 text fields at the same time by using one scroll bar? -
Scroll text with scroll bar
I've created a chunk of text and I want it to scroll in a window. Managed to put a scroll bar on it, but cannot figure out how to size the window and... -
Scroll help
I don't know how to scroll texts and graphics. i mean i want to scroll them at the control of mouse (i'm not talking abt movie). Currently i'm using... -
scroll bar use!
in big pages i put a scroll bar so it can fits better the text. but as i put fields and text on the text in play mode only main text moves and other... -
Elefterios Melissaratos #2
Re: Q: Scroll to a Row?
"Soul" <no@spam.com> wrote in message news:<emIskxJdDHA.2860@TK2MSFTNGP11.phx.gbl>...
> Hi,
>
> I have DataGrid on a C# Windows Application. Can I know how can I scroll to
> a particular row in the DataGrid?
>
> Thank you.
Hi Soul
FYI this is the group for ASP.NET datagrid and not for Windows Forms.
However here is my answer to your question:
You have to use the concept of the CurrencyManager in windows forms.
Then you can scroll to a specific row by aasigning the appropriate value
to the Position property of the CurrencyManager object.
Lets say that you bind DataTable dt to a Datagrid dataGrd. Then
you have :
DataGrd.DataSource = dt;
cm = (CurrencyManager)this.BindingContext[dt];
cm.Position = 2; // scrolls to the second row of the datagrid
I include the full code below:
On the Load event of your form populate the datagrid see below
private void DatagridBinding_Load(object sender, System.EventArgs e)
{
// Create a Datatable to bind it to the Datagrid
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("FirstName",System.Type.GetType("System .String"));
dt.Columns.Add(dc);
dc = new DataColumn("LastName",System.Type.GetType("System. String"));
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr["FirstName"] = "Donald";
dr["LastName"] = "Knuth";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["FirstName"] = "Richard";
dr["LastName"] = "Karp";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["FirstName"] = "Jim";
dr["LastName"] = "Gray";
dt.Rows.Add(dr);
DataGrd.DataSource = dt;
cm = (CurrencyManager)this.BindingContext[dt];
cm.Position = 0;
}
and then you can scroll to row 1 by cm.Position = 1 etc.
Regards
Lefteris
Elefterios Melissaratos Guest
-
Soul #3
Re: Q: Scroll to a Row?
Thanks, it work
--
Soul
"Elefterios Melissaratos" <leftim@yahoo.com> wrote in message
news:40183e.0309061653.a7fed7e@posting.google.com. ..
| "Soul" <no@spam.com> wrote in message
news:<emIskxJdDHA.2860@TK2MSFTNGP11.phx.gbl>...
|
| [Snipped]
|
Soul Guest



Reply With Quote

