By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

filter & datagrid

P: n/a
sg
Hi

I'm starting programming in visual studio and c# and i have a problem
with filtering datagrid. I build form with datagrid and i see data from
database. I find in microsoft web page information how to create
filtering data grid but this doesn't work. What I must change? My form code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'minicrmDataSet1.adresy' table. You can move, or remove it, as needed.
this.adresyTableAdapter1.Fill(this.minicrmDataSet1 .adresy);
}

//from microsoft web page
private void MakeDataView()
{

DataView dv = new DataView();

dv.Table = minicrmDataSet1.Tables["adresy"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "imie = 'Berlin'";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "imie DESC";

// Simple bind to a TextBox control
Text1.DataBindings.Add("Text", dv, "imie");
}
//

}
}

Thank you in advance for your help

Sebastian
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

"sg" <sg***@poczta.onet.pl> wrote in message
news:dl**********@news.onet.pl...
Hi

I'm starting programming in visual studio and c# and i have a problem with
filtering datagrid. I build form with datagrid and i see data from
database. I find in microsoft web page information how to create filtering
data grid but this doesn't work. What I must change? My form code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'minicrmDataSet1.adresy' table. You can move, or remove it, as needed.
this.adresyTableAdapter1.Fill(this.minicrmDataSet1 .adresy);
}

//from microsoft web page
private void MakeDataView()
{

DataView dv = new DataView();
I don't see you assign this new DataView to something and instead of
creating a new one, you can use the one BindingSource already uses:

DataView dv = (DataView)this.adresyBindingSource.List;

Any filtering on that DataView should be visible in the grid.
HTH,
Greetings

dv.Table = minicrmDataSet1.Tables["adresy"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "imie = 'Berlin'";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "imie DESC";

// Simple bind to a TextBox control
Text1.DataBindings.Add("Text", dv, "imie");
}
//

}
}

Thank you in advance for your help

Sebastian

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.