Parsing of data filtering and sorting------

Source: Internet
Author: User

One. TreeView

SelectedNode The selected node
Depth of level node (starting from 0)
Occurs when the AfterSelect node is selected

1. Get the node depth


2. Get the node name


Two. Filtering and sorting Data using DataView

RowFilter Specifying filter criteria
Sort specifies how the order is sorted

All is selected by default when the form is run
if (This.tvstulist.SelectedNode.Level = = 0) {
Showstudent ();
else if (This.tvstulist.SelectedNode.Level = = 1) {
DataView dv = new DataView (ds. tables["Student"]);
Dv. RowFilter = "Gradename=" "+this.tvstulist.selectednode.text+" ";
This.dgvstulist.DataSource = DV;
else if (This.tvstulist.SelectedNode.Level = = 2) {

DataView dv = new DataView (ds. tables["Student"]);
Dv. RowFilter = "Gradename=" + This.tvstulist.SelectedNode.Parent.Text + "' and sex= '" + This.tvstulist.SelectedNode.Text + " ‘";
Dv. Sort = "Studentno desc";

Three. Delete data

SelectionMode Specifies the selected Datagradeview selection method

DialogResult result= MessageBox.Show ("Whether delete", "hint", messageboxbuttons.yesno,messageboxicon.information);
if (result = = Dialogresult.yes) {
Gets the value of the selected study number
int studentno= (int) this.dgvstulist.selectedrows[0]. cells["Studentno"]. Value;
Helper. OpenConnection ();
String sql = "Delete from Student where studentno= '" "+studentno+" ";
SqlCommand cmd = new SqlCommand (sql,helper. Con);
int Count=cmd. ExecuteNonQuery ();
if (Count > 0)
MessageBox.Show ("Delete succeeded! "," hint ", MessageBoxButtons.OK, MessageBoxIcon.Information);
Showstudent ();
else {
MessageBox.Show ("Delete failed! "," hint ", MessageBoxButtons.OK, MessageBoxIcon.Information);
catch (Exception x)
MessageBox.Show (X.message);

Parsing of data filtering and sorting------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.