Discussion:
[Gambas-user] search in gridview or columnview
Peter Mathijssen
2008-06-03 12:08:33 UTC
Permalink
Hello,

I have a application in wich i want to use a columnview or a gridview. I am
searching for some code to search the gridview or columnview for a piece of
text. The grid will be two columns wide.
I want the rows that contain the found text selected.

I found a piece of code to search a columnview but it doesn't do exactly
what i want.

I am in the proces of making this app. that i developed in realbasic again
in gambas.
http://plekzondernaam.wordpress.com/not2complex/

The gambas version looks like this now:
Loading Image...

I am also looking for a piece of code to fill the gridview or columnview
with a tab-delimited file. So one piece of text goes in column 1 and the
other piece in column 2.

Does someone have this already?

Thanks in advance.

Peter Mathijssen
Stefano Palmeri
2008-06-03 15:34:40 UTC
Permalink
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a gridview. I am
searching for some code to search the gridview or columnview for a piece of
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do exactly
what i want.
I've attached a gridview example. It selects rows which contains "hello".
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic again
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or columnview
with a tab-delimited file. So one piece of text goes in column 1 and the
other piece in column 2.
--------------------------------------------------------------------
DIM sStringArray as String[]
DIM sWord as string

sStringArray = split(file.load("path to file"), "\t")

for each sWord in sStringArray

'here fill the grid

next

---------------------------------------------------

bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter Mathijssen
2008-06-03 17:04:08 UTC
Permalink
Hi Stefano,

Thank you very much. I played a bit with your code and changed it to:


DIM iCountCol, iCountRow AS Integer

IF Len(txtsearch.text) = 0 THEN RETURN

GridView1.Mode = Select.Multiple

FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text) > 0
THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT

This way rows get selected when only a part of the text is found. I put the
routine in a textbox_change event.
Do you know how to get the row that has been clicked on with the mouse. I
want to select it.

I wonder is a gridview right for this sort of thing, or is a columnview
better?

Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a gridview. I
am
Post by Peter Mathijssen
searching for some code to search the gridview or columnview for a piece
of
Post by Peter Mathijssen
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do exactly
what i want.
I've attached a gridview example. It selects rows which contains "hello".
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic
again
Post by Peter Mathijssen
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or columnview
with a tab-delimited file. So one piece of text goes in column 1 and the
other piece in column 2.
--------------------------------------------------------------------
DIM sStringArray as String[]
DIM sWord as string
sStringArray = split(file.load("path to file"), "\t")
for each sWord in sStringArray
'here fill the grid
next
---------------------------------------------------
bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Stefano Palmeri
2008-06-03 17:50:24 UTC
Permalink
Post by Peter Mathijssen
Hi Stefano,
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN RETURN
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text) > 0
THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
This way rows get selected when only a part of the text is found. I put the
routine in a textbox_change event.
Do you know how to get the row that has been clicked on with the mouse. I
want to select it.
PUBLIC SUB GridView1_Click()

PRINT LAST.Row

END
Post by Peter Mathijssen
I wonder is a gridview right for this sort of thing, or is a columnview
better?
I don't know :-)
It really depends on what you're doing...

Stefano
Post by Peter Mathijssen
Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a gridview. I
am
Post by Peter Mathijssen
searching for some code to search the gridview or columnview for a piece
of
Post by Peter Mathijssen
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do
exactly what i want.
I've attached a gridview example. It selects rows which contains "hello".
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic
again
Post by Peter Mathijssen
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or
columnview with a tab-delimited file. So one piece of text goes in
column 1 and the other piece in column 2.
--------------------------------------------------------------------
DIM sStringArray as String[]
DIM sWord as string
sStringArray = split(file.load("path to file"), "\t")
for each sWord in sStringArray
'here fill the grid
next
---------------------------------------------------
bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-----------------------------------------------------------------------
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter Mathijssen
2008-06-03 18:10:27 UTC
Permalink
Hi Stefano,

I put this in a gridview_click event

GridView1.Rows[LAST.row].Selected = TRUE

But nothing happens, when i use print last.row it works fine.

Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hi Stefano,
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN RETURN
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text) >
0
Post by Peter Mathijssen
THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
This way rows get selected when only a part of the text is found. I put
the
Post by Peter Mathijssen
routine in a textbox_change event.
Do you know how to get the row that has been clicked on with the mouse. I
want to select it.
PUBLIC SUB GridView1_Click()
PRINT LAST.Row
END
Post by Peter Mathijssen
I wonder is a gridview right for this sort of thing, or is a columnview
better?
I don't know :-)
It really depends on what you're doing...
Stefano
Post by Peter Mathijssen
Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a
gridview.
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I
am
Post by Peter Mathijssen
searching for some code to search the gridview or columnview for a piece
of
Post by Peter Mathijssen
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do
exactly what i want.
I've attached a gridview example. It selects rows which contains
"hello".
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic
again
Post by Peter Mathijssen
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or
columnview with a tab-delimited file. So one piece of text goes in
column 1 and the other piece in column 2.
--------------------------------------------------------------------
DIM sStringArray as String[]
DIM sWord as string
sStringArray = split(file.load("path to file"), "\t")
for each sWord in sStringArray
'here fill the grid
next
---------------------------------------------------
bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-----------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Stefano Palmeri
2008-06-03 18:16:21 UTC
Permalink
Post by Peter Mathijssen
Hi Stefano,
I put this in a gridview_click event
GridView1.Rows[LAST.row].Selected = TRUE
But nothing happens, when i use print last.row it works fine.
Peter
But when you click on a row it's automatically selected;
the row should turn its background color.
I can't understand.

Stefano
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Hi Stefano,
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN RETURN
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text)
0
Post by Peter Mathijssen
THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
This way rows get selected when only a part of the text is found. I put
the
Post by Peter Mathijssen
routine in a textbox_change event.
Do you know how to get the row that has been clicked on with the mouse.
I want to select it.
PUBLIC SUB GridView1_Click()
PRINT LAST.Row
END
Post by Peter Mathijssen
I wonder is a gridview right for this sort of thing, or is a columnview
better?
I don't know :-)
It really depends on what you're doing...
Stefano
Post by Peter Mathijssen
Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a
gridview.
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I
am
Post by Peter Mathijssen
searching for some code to search the gridview or columnview for a piece
of
Post by Peter Mathijssen
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do
exactly what i want.
I've attached a gridview example. It selects rows which contains
"hello".
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic
again
Post by Peter Mathijssen
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or
columnview with a tab-delimited file. So one piece of text goes in
column 1 and the other piece in column 2.
--------------------------------------------------------------------
DIM sStringArray as String[]
DIM sWord as string
sStringArray = split(file.load("path to file"), "\t")
for each sWord in sStringArray
'here fill the grid
next
---------------------------------------------------
bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-----------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-----------------------------------------------------------------------
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter Mathijssen
2008-06-03 18:30:11 UTC
Permalink
Hi Stefano,

Stupid me, i forgot to set the selection mode. Shame on me.
Now it works.

Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hi Stefano,
I put this in a gridview_click event
GridView1.Rows[LAST.row].Selected = TRUE
But nothing happens, when i use print last.row it works fine.
Peter
But when you click on a row it's automatically selected;
the row should turn its background color.
I can't understand.
Stefano
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Hi Stefano,
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN RETURN
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text,
txtsearch.Text)
Post by Peter Mathijssen
Post by Stefano Palmeri
0
Post by Peter Mathijssen
THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
This way rows get selected when only a part of the text is found. I
put
Post by Peter Mathijssen
Post by Stefano Palmeri
the
Post by Peter Mathijssen
routine in a textbox_change event.
Do you know how to get the row that has been clicked on with the
mouse.
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I want to select it.
PUBLIC SUB GridView1_Click()
PRINT LAST.Row
END
Post by Peter Mathijssen
I wonder is a gridview right for this sort of thing, or is a
columnview
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
better?
I don't know :-)
It really depends on what you're doing...
Stefano
Post by Peter Mathijssen
Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a
gridview.
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I
am
Post by Peter Mathijssen
searching for some code to search the gridview or columnview for
a
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
piece
of
Post by Peter Mathijssen
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do
exactly what i want.
I've attached a gridview example. It selects rows which contains
"hello".
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
I am in the proces of making this app. that i developed in realbasic
again
Post by Peter Mathijssen
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or
columnview with a tab-delimited file. So one piece of text goes
in
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
column 1 and the other piece in column 2.
--------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Post by Stefano Palmeri
DIM sStringArray as String[]
DIM sWord as string
sStringArray = split(file.load("path to file"), "\t")
for each sWord in sStringArray
'here fill the grid
next
---------------------------------------------------
bye
Post by Peter Mathijssen
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-----------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
Post by Stefano Palmeri
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-----------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
Post by Peter Mathijssen
-- This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
Post by Peter Mathijssen
Post by Stefano Palmeri
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter Mathijssen
2008-06-04 13:36:38 UTC
Permalink
It seems that this code:

DIM iCountCol, iCountRow AS Integer

IF Len(txtsearch.text) = 0 THEN
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
GridView1.Rows[iCountRow].Selected = FALSE
NEXT
RETURN
END IF

GridView1.Mode = Select.Multiple

FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
gb.Case) > 0 THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT

only finds strings in column 1 and not in column 0.
It is a gridview with two columns, both columns contain strings of text.

Strange, the code looks fine. I just adapted it a bit from Stefano.

Peter
Stefano Palmeri
2008-06-04 14:25:33 UTC
Permalink
Post by Peter Mathijssen
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
GridView1.Rows[iCountRow].Selected = FALSE
NEXT
RETURN
END IF
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
gb.Case) > 0 THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
only finds strings in column 1 and not in column 0.
It is a gridview with two columns, both columns contain strings of text.
Strange, the code looks fine. I just adapted it a bit from Stefano.
Peter
-------------------------------------------------------------------------
Hi, Peter.

It seems you forget a BREAK. In the way you wrote
the code, the same Row could be selected and
unselected in the same loop.
To fix it add a BREAK when the Row is selected:

IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
gb.Case) > 0 THEN
GridView1.Rows[iCountRow].Selected = TRUE
BREAK

Example attached.

Bye,

Stefano
Post by Peter Mathijssen
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter Mathijssen
2008-06-04 14:31:50 UTC
Permalink
Thanks again Stefano,

Now it's working ok.

Still learning every time ;-)

Peter
Post by Stefano Palmeri
Post by Peter Mathijssen
DIM iCountCol, iCountRow AS Integer
IF Len(txtsearch.text) = 0 THEN
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
GridView1.Rows[iCountRow].Selected = FALSE
NEXT
RETURN
END IF
GridView1.Mode = Select.Multiple
FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
gb.Case) > 0 THEN
GridView1.Rows[iCountRow].Selected = TRUE
ELSE
GridView1.Rows[iCountRow].Selected = FALSE
ENDIF
NEXT
NEXT
only finds strings in column 1 and not in column 0.
It is a gridview with two columns, both columns contain strings of text.
Strange, the code looks fine. I just adapted it a bit from Stefano.
Peter
-------------------------------------------------------------------------
Hi, Peter.
the code, the same Row could be selected and
unselected in the same loop.
IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
gb.Case) > 0 THEN
GridView1.Rows[iCountRow].Selected = TRUE
BREAK
Example attached.
Bye,
Stefano
Post by Peter Mathijssen
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Jerry Clement
2008-06-03 22:58:32 UTC
Permalink
Post by Peter Mathijssen
Hello,
I have a application in wich i want to use a columnview or a gridview. I am
searching for some code to search the gridview or columnview for a piece of
text. The grid will be two columns wide.
I want the rows that contain the found text selected.
I found a piece of code to search a columnview but it doesn't do exactly
what i want.
I am in the proces of making this app. that i developed in realbasic again
in gambas.
http://plekzondernaam.wordpress.com/not2complex/
http://img112.imageshack.us/img112/8049/not2complexgambasky5.png
I am also looking for a piece of code to fill the gridview or columnview
with a tab-delimited file. So one piece of text goes in column 1 and the
other piece in column 2.
Does someone have this already?
Thanks in advance.
Peter Mathijssen
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Peter,

Thanks for the links to your NotToComplex program. I downloaded the
RealBasic one and it's great for a newbie like me. Please post and share the
Gambas code when you get it completed. I'm sure I could learn a lot from
your coding. Again, Thanks,
Jerry
Nashville, TN
:jumping::jumping::jumping:
--
View this message in context: http://www.nabble.com/search-in-gridview-or-columnview-tp17622083p17635704.html
Sent from the gambas-user mailing list archive at Nabble.com.
Loading...