Sorting data using BindingSource C#.Net

03/05/2007 - 11:07 por Peter Matogo | Informe spam
Hello people,

I have a problem that has been nagging me for quite some time now...let
me give you a brief description:

I have on my form 4 controls:
-An ordinary TextBox
-A DataGridView
-A DataSet
-and a BindingSource
the DataSource for the DataGridView is the BindingSource control. The
data source for the BindingSource is the DataSet.
So when the user enters some text in the TextBox the DataGridView is
automatically filtered. I used the following line of code to apply the
filter:
productsBindingSource.Filter = string.Format("Name like '%{0}%'",
txtFilter.Text);

that works fine

now the problem comes in when i try to get the index of the filtered
data in the DataGridView.For example, the first item in the filtered
text picks the first item in the original set.
So how can i update or refresh the data after I apply the filter??
Any help will be greatly appreciated

*** Sent via Developersdex http://www.developersdex.com ***

Preguntas similare

Leer las respuestas

#1 ANT1
03/05/2007 - 11:34 | Informe spam
On 3 mayo, 11:07, Peter Matogo wrote:
Hello people,

I have a problem that has been nagging me for quite some time now...let
me give you a brief description:

I have on my form 4 controls:
-An ordinary TextBox
-A DataGridView
-A DataSet
-and a BindingSource
the DataSource for the DataGridView is the BindingSource control. The
data source for the BindingSource is the DataSet.
So when the user enters some text in the TextBox the DataGridView is
automatically filtered. I used the following line of code to apply the
filter:
productsBindingSource.Filter = string.Format("Name like '%{0}%'",
txtFilter.Text);

that works fine

now the problem comes in when i try to get the index of the filtered
data in the DataGridView.For example, the first item in the filtered
text picks the first item in the original set.
So how can i update or refresh the data after I apply the filter??
Any help will be greatly appreciated

*** Sent via Developersdexhttp://www.developersdex.com***



If datagridview.refresh() doesn't work try to unbind de source and
rebind it.

datagridview.datasource = null;
datagridview.datasource = yourdatabindingsource;
Respuesta Responder a este mensaje
#2 ANT1
03/05/2007 - 11:42 | Informe spam
If datagridview.refresh() doesn't work try to unbind de source and
rebind it.

datagridview.datasource = null;
datagridview.datasource = yourdatabindingsource;



Sorry I clicked to send de post before finish de coment.

Before rebind the datasource make the datagridview.Refresh();

I'm not sure if it's that what you are asking to, but hope it'll help
you.
Respuesta Responder a este mensaje
#3 Juan Diego Bueno
03/05/2007 - 11:57 | Informe spam
Sorry I clicked to send de post before finish de coment.



ANT1, nos tienes que explicar esa nueva forma de españolizar
"the" (suponiendo que fuera lo que quisieras poner). Hubiera quedado
más rapero (en plan don't believe da hype) que hubieras usado "da" xD

Na, es coña... Supongo que este hombre te haya entendido, aunque este
sea un grupo de noticias en castellano.

Saludos
Respuesta Responder a este mensaje
#4 ANT1
03/05/2007 - 11:59 | Informe spam
On 3 mayo, 11:57, Juan Diego Bueno wrote:
> Sorry I clicked to send de post before finish de coment.

ANT1, nos tienes que explicar esa nueva forma de españolizar
"the" (suponiendo que fuera lo que quisieras poner). Hubiera quedado
más rapero (en plan don't believe da hype) que hubieras usado "da" xD

Na, es coña... Supongo que este hombre te haya entendido, aunque este
sea un grupo de noticias en castellano.

Saludos



Jejeje

Ya he visto, me pasa bastante a menudo, me distraigo y escribo mal el
"the". Ademas veo que lo he puesto mal un par de veces.

Espero realmente que lo entendiese. Jeje
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida