Hi!
Sorry it should be DataGridView...
Here is a code snippet how it looks today
I use this form to select a value from a table. If a value is already in the
calling TextBox, i want to
place the "cursor" on the row in the lookup form
/Martin
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ControlDBLookup
{
public partial class Lookup : Form
{
private string TableSchema;
private string TableName;
private SqlConnection conn;
private string[] DisplayColumns;
private DataSet LookupData;
private DBLookup theLookup;
public string Lookup_TableSchema
{
set { TableSchema = value; }
}
public string Lookup_TableName
{
set { TableName = value; }
}
public SqlConnection Lookup_SqlConnection
{
set { conn = value; }
}
public string[] Lookup_DisplayColumns
{
set { DisplayColumns = value; }
}
public DataSet Lookup_LookupData
{
get { return LookupData; }
}
public Lookup(DBLookup ALookup)
{
InitializeComponent();
theLookup = ALookup;
}
private void Lookup_Load(object sender, EventArgs e)
{
if (conn != null)
{
DBHelper db = new DBHelper(conn);
LookupData = db.GetLookupData(TableSchema, TableName, DisplayColumns);
if (LookupData != null)
{
gvLookupData.DataSource = LookupData;
gvLookupData.DataMember = LookupData.Tables[0].TableName;
}
}
}
private void btnOK_Click(object sender, EventArgs e)
{
theLookup.ValueData = gvLookupData.CurrentRow.Cells[0].Value;
this.Close();
}
}
}
"Cor Ligthert [MVP]" <no************@planet.nlskrev i meddelandet
news:eS**************@TK2MSFTNGP03.phx.gbl...
Martin,
You are making a message that is very confusing,
Are you writing in your subject about a GridView and therefore a
WebApplication and therefore using a datareader, or are you talking as in
your text about a DataGridView and therefore a windowforms application and
confuse us even more that you are not using a dataadapter or tableadapter
to get the dataset.
(By the way, in a webapplication it would in my idea as well more
efficient to use the two last ones, to be sure your dataset is correct and
the positioning using the bindingsource goes well).
So maybe can you help us to come out of this confusing things?
Cor
"Martin Arvidsson" <ye*******@ms.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hi!
I have used the SqlCommand and DataReader to read data to a DataSet
This dataset is the used to set the properties; DataMember and DataSource
of the DataGridView.
Now what i want to do is to go to a specific row of the DataGridView.
I have tried to use a BindingSource to find the value and the issue a
position, but it doesn't work
What i want to do is when i acces the grid wich is called as a prompt i
want to position my self on the value based on the field that i call the
lookup from....
Regards
Martin