G
Gina_Marano
Hey All,
I have the following code example where the user gives me a query and
I populate a grid:
private void btnTestSQL_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(sSrcConnectionStr);
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(eSqlText.Text,
conn);
da.Fill(ds, "data");
gTest.DataSource = ds;
gTest.DataMember = "data";
ds = null;
da = null;
}
finally
{
conn.Close();
conn.Dispose();
}
}
Works great!
Next I want to navigate through the grid and as I navigate the current
row is highlighted. I know this is inefficient with large datasets but
I want the visual feedback to the user.
I found how to do this using the currencymanager but I also want the
physical grid row to be highlighted as I traverse the grid.
CurrencyManager cm =
(CurrencyManager)this.BindingContext[gTest.DataSource];
int rowCount = cm.Count;
Why does rowCount = 1 when I have 10 rows?
At design time I don't know what column a field value will be in but I
know that the field value must be in the datasource some where. So I
will need to be able to determine that as well.
Thanks much
~Gina_M~
I have the following code example where the user gives me a query and
I populate a grid:
private void btnTestSQL_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(sSrcConnectionStr);
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(eSqlText.Text,
conn);
da.Fill(ds, "data");
gTest.DataSource = ds;
gTest.DataMember = "data";
ds = null;
da = null;
}
finally
{
conn.Close();
conn.Dispose();
}
}
Works great!
Next I want to navigate through the grid and as I navigate the current
row is highlighted. I know this is inefficient with large datasets but
I want the visual feedback to the user.
I found how to do this using the currencymanager but I also want the
physical grid row to be highlighted as I traverse the grid.
CurrencyManager cm =
(CurrencyManager)this.BindingContext[gTest.DataSource];
int rowCount = cm.Count;
Why does rowCount = 1 when I have 10 rows?
At design time I don't know what column a field value will be in but I
know that the field value must be in the datasource some where. So I
will need to be able to determine that as well.
Thanks much
~Gina_M~