|
Thank you for elaborating, I am pretty new to this whole thing.
But my question is still how do I loop through these cells(only in one column) to actually get the content of the cell into a variable string. I understand the logic I am just not sure on how to actually pull the content out of the cell for usage.
thanks,
zach
|
|
|
|
|
Hi,
I haven't used DataGridView myself, here is my best guess:
- DGV has a property called Rows, this holds all the rows, so you can iterate them
with a foreach (DataGridViewRow row in myDGV.Rows) {...}
- a DataGridViewRow has a property called Cells, this holds all the cells of that
row, as in one array; you can apply an index to them as in
row.Cells[i];
- with the above, you could access all the cells that belong to a single column,
provided you now the index of that column. If you have to find out that index,
well DGV has a property called Columns, this holds all the column descriptions
(not the data, just metadata).
I hope and think that would put you on track.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
How about this:
Create a dataview filtering on column TABLE_NAME like %data.
Then just loop through this dataview.
Guy
You always pass failure on the way to success.
|
|
|
|
|
Sounds interesting, could you say more about filtering on a column, I do not have the slightest clue as how to do this. Would it be done with SQL statement or in VB.NET code?
thanks,
Zach
|
|
|
|
|
I need a way to determine whether a word (or character) is selected outside of my application or not
do we have any appropriate API function for this purpose?
A.E.K
|
|
|
|
|
AFAIK that is impossible to know.
There may be several items selected in several controls all over the place,
and Windows does not know that. Selection is a matter internal to the Control
or other object that supports it.
You can interrogate the clipboard.
You could start sending CTRL/C to different controls, and watch the clipboard.
But a Control does not have to obey CTRL/C...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
There's no way to tell and no API to call to tell you.
There are simply too many different controls out there handling text is so many different ways. It's entirely up to the control containing the text in question. There's no standard method anyn control uses to expose this information.
|
|
|
|
|
A.E.K wrote: I need a way to determine whether a word (or character) is selected outside of my application or not
do we have any appropriate API function for this purpose?
Is the other application (2nd one) where the text is selected also a custom application? If it is you could use a standard Windows OS Message to notify your 1st application when text is selected.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
i agreed with him and want to add some more clarification in these comments that if other application is custome application and you have the source available then you can raise an event for the selection you have made.
Hope you got the idea.
Be a part of solution, rather then be a part of problem
|
|
|
|
|
Nope.
it should work every where.
thanks everybody.
A.E.K
|
|
|
|
|
A.E.K wrote: Nope.
it should work every where.
thanks everybody.
That can not be easily done, and you shouldn't need to do something like that either for a typical application. Perhaps you need to reconsider your application design?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
I have a datagridview control and all i'm wondering is if there's a way I can select all the contents (and the columns) and store in a variable
|
|
|
|
|
try this
Dim arr(dgv1.RowCount * dgv1.ColumnCount - 1) As DataGridViewCell
dgv1.SelectAll()
dgv1.SelectedCells.CopyTo(arr, 0)
A.E.K
|
|
|
|
|
that put it in the variable arr right? Since it's in an array, how would I output that into a textbox or something similar
|
|
|
|
|
use the Value proeprty of DataGridViewCell .
A.E.K
|
|
|
|
|
Is there any way to make a .net webpage, and in the server script to grab the URL and save the content to actual HTML file?
|
|
|
|
|
Simple answer: yes.
In the code behind you will need to utilize a component (or write one) that makes the http request to the server running the .net webform and cache the response.
The simplest mechanism would be to open a socket to port 80 (unless you're running https) of the server, send the GET or POST request and cache the response. You'll need to strip off the HTTP headers.
eg. send:
<br />
GET /some/dotnet/file.aspx HTTP/1.1
check the reponse contains:
HTTP/1.1 200 OK
in the first line.
To strip off the HTTP headers in the response, look for the first empty line. The HTML content should be after that.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Here is a function that lets you do that:
Public Function GetWebPageResult(ByVal webPG As String) As String<br />
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(webPG), HttpWebRequest)<br />
<br />
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)<br />
<br />
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()<br />
<br />
Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")<br />
<br />
Dim readStream As New StreamReader(receiveStream, encode)<br />
GetWebPageResult = readStream.ReadToEnd() ' Use this 'readStream' where ever you want.<br />
<br />
End Function
Just call this function and pass the webpage URL to it. It will grab the html content of the page and return it as a string as the result of the function.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi,
IMO you should Close both the WebResponse and the Stream inside your function.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: IMO you should Close both the WebResponse and the Stream inside your function.
LOL... oops.... my bad.
Yeah, make sure to close both those.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
I'd forgotten about that class, cheers. Been working on winforms too long!
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Hi Digi, thatnks for the reply.
The function is awesome. it works like charm ^^
BTW, i just find out another solution, to share with you guys here =D
I used webclient class, there is a readopen() method to achieve this.
here is a sample class which i get from msdn.
Public Class Test
Public Shared Sub Main(args() As String)
If args Is Nothing OrElse args.Length = 0 Then
Throw New ApplicationException("Specify the URI of the resource to retrieve.")
End If
Dim client As New WebClient()
' Add a user agent header in case the
' requested URI contains a query.
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
Dim data As Stream = client.OpenRead(args(0))
Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd()
Console.WriteLine(s)
data.Close()
reader.Close()
End Sub 'Main
End Class 'Test
|
|
|
|
|
How do I get my app to display a console window?
(As in the little black screen)
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
I think there is a function GetConsoleWindow but I'm not 100%.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|