RubenPieters

Hello,

So what I want is after I press a button my picturebox goes up, but it may not go up if theres another picturebox in its way.

So is it possible to filter my datatable, kaartinfo, and look if theres a picturebox in the way in the row xloc and see if theres a picturebox already if not, he can go up, if there is one in the way he can't go up.

Is this possible to do if yes, how can I do it

thx in advance

Ruben



Re: Visual C# Express Edition 'filtering' after clicking on a button

Riquel Dong ¨C MSFT

Hi Ruben,

Would you clarify your question What do you mean ¡°picturebox goes up, but it may not go up if theres another picturebox in its way¡± After filtering your datatable, what do you want Hope to receive your question again.

Thanks for your question






Re: Visual C# Express Edition 'filtering' after clicking on a button

RubenPieters

"What do you mean ¡°picturebox goes up, but it may not go up if theres another picturebox in its way¡± "

Well I want my picturebox to go up, but not if theres already a picturebox at the same location

"After filtering your datatable, what do you want "

I want to see if there are any results, and if there are, then my picturebox may not go up, but if there aren't any results from the filtering then I want my picturebox to go up





Re: Visual C# Express Edition 'filtering' after clicking on a button

Riquel Dong ¨C MSFT

Hi,

You can put your picturebox to top by using picturebox.BringToFront() method. You need to compare your picturebox position with other picturebox position to decide if other picturebox occupies the same location. Based on your filtering results, you can decide whether you put picturebox to top or not . If you have any further questions please let me know.

Good luck






Re: Visual C# Express Edition 'filtering' after clicking on a button

RubenPieters

yes that's what I want to do, but instead of using BringToFront() I want my picturebox to go higher in location ^^ I do that with picturebox.top -= 21

but my question is, how do I do it =) How do I filter and compare the filter results





Re: Visual C# Express Edition 'filtering' after clicking on a button

Riquel Dong ¨C MSFT

Hi,

Based on your post, you can use the following code to move your picturebox control in form.

Code Snippet

pictureBox1.Location = new Point(200, 300);

pictureBox2.Location = new Point(20, 20);

this.Invalidate();

At last , you want to filter data. Then you can see only a subset of the records . You can use built-in dataset features to filter data. You have threeo options:

1 Data tables support a Select method that you can call to filter and sort. The method does not change the contents or order of records in a table; instead, it presents you with a list of records (an array) representing the criteria you specify. Here is good exmple to you. For more information, visit:

http://msdn2.microsoft.com/en-us/library/system.data.datatable.select(VS.71).aspx

2 You can use a data view (DataView object). A data view is an object that acts as a layer on top of the data table, providing a filtered and sorted view of the table's contents. A data view is similar to a view in a database, in that it is not a copy of the data. Instead, it is simply a different way of seeing the data in a table. For more information, visit:

http://msdn2.microsoft.com/en-us/library/system.data.dataview(VS.71).aspx

3 You can re-execute SQL commands to fetch specific data.But because the dataset is disconnected from the data source, it is often impractical and resource-intensive . You'd better use two above methods.Here is simple example.

Code Snippet

private void Button3_Click(object sender, System.EventArgs e)

{

OleDbCommand sql = new OleDbCommand("SELECT * FROM Employees WHERE EmployeeID> @id");

sql.Parameters.AddWithValue("@id", textBox1.Text);

OleDbDataAdapter DataAdapter1 = new OleDbDataAdapter(sql);

DataSet ds = new DataSet();

DataAdapter1.Fill(ds, "Employees");

DataGridView1.DataSource = ds;

DataGridView1.DataMember = "Employees";

}

Hope this can help you.

Good luck






Re: Visual C# Express Edition 'filtering' after clicking on a button

RubenPieters

I have look a bit in those things u linked, and I have tried a bit with it, though I don't rly get it working, this is the thing I have atm:

(I have changed some things so it fits my form, not sure if its edited correct though =x)

private void GetRowsByFilter()

{

int XLoc = Convert.ToInt32(label1.Text);

DataTable myTable;

Database1DataSet1 DataSet1 = new Database1DataSet1();

myTable = DataSet1.Tables["Table1"];

// Presuming the DataTable has a column named Date.

string strExpr;

strExpr = "xLoc = XLoc";

DataRow[] foundRows;

// Use the Select method to find all rows matching the filter.

foundRows = myTable.Select(strExpr);

// Print column 0 of each returned row.

for (int i = 0; i < foundRows.Length; i++)

{

listBox1.Items.Add(foundRowsIdea[0]);

}

}

What I want is that it adds the found rows in my listbox, but atm it doesn't do anything, so is there anything I'm doing wrong

the original thing comes from here: http://msdn2.microsoft.com/en-us/library/aa325668(VS.71).aspx