|
Hello,
I am a noob to C# and would like to know the best method of parsing HTML. Here is an example of what I will be doing a lot of.
I would like to get the following variables
strVis = Detroit
intVisScore = 4
strHome = N.Y. Yankees
intHomeScore = 3
strInning = Final
strBoxScore = http://www.usatoday.com/sports/scores106/106278/MLB725547.htm
If you have something generic w/ good documentation I should be ok w/ that . I like learning the HOW.
Thanks!
Ryan
|
|
|
|
|
You can use a regular expression to parse the string.
As a lot of your example doesn't show up in the forum (as you haven't used the Ignore HTML feature), I can't really make a meaningful example from it. Here is an example from MSDN:
string text = "One car red car blue car";
string pat = @"(\w+)\s+(car)";
Regex r = new Regex(pat, RegexOptions.IgnoreCase);
Match m = r.Match(text);
int matchCount = 0;
while (m.Success)
{
Console.WriteLine("Match"+ (++matchCount));
for (int i = 1; i <= 2; i++)
{
Group g = m.Groups[i];
Console.WriteLine("Group"+i+"='" + g + "'");
CaptureCollection cc = g.Captures;
for (int j = 0; j < cc.Count; j++)
{
Capture c = cc[j];
System.Console.WriteLine("Capture"+j+"='" + c + "', Position="+c.Index);
}
}
m = m.NextMatch();
}
---
b { font-weight: normal; }
|
|
|
|
|
Could you enlighten me to the ignore HTML?
Thanks
|
|
|
|
|
You don't ignore the HTML, you use it to identify the information that you want.
If you have the string "...something...<table><tr><td>some info</td></tr></table>...something...", you can use the pattern "<table><tr><td>([^<]+)</td></tr></table>" to get the information.
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I have I a class that inherits from TabConrol called MyControl. I have a class that inherits from TabPage called MyTabPage, as below:
(heavily simplified)
class MyTabControl:TabControl<br />
{<br />
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs ke)<br />
{<br />
(this.SelectedTab as MyTabPage).PanelContained.KDown(ke);<br />
base.OnKeyDown(ke);<br />
}<br />
}<br />
class MyTabPage : TabPage<br />
{<br />
private MyPanel panelContained;<br />
public MyPanel PanelContained{<br />
get { return panelContained; }<br />
set { panelContained = value; }<br />
}<br />
}
How can I override SelectedTab to return a MyTabPage? If I add a MyTabPage and change the panelcontained property, this is null again when I convet it back from SelectedTab.
Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?
cheeers
|
|
|
|
|
thepersonof wrote: How can I override SelectedTab to return a MyTabPage?
You can't change the return type or the method parameter types in an overload.
thepersonof wrote: Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?
<br />
TabControl tabs = new MyTabPage();
Since tab control does not have the PanelContained property you will not beable to use it in tabs
unless its cast back up to MyTabPage. Even though the compatible TabControl contains a MyTabPage the PanelContained property will not be exposed. You will have to do this.
<br />
((MyTabPage)tabs).PanelExposed<br />
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
Thank you. I can't manage to make the method you suggest work, does anyone have any other suggestions?
thanks
|
|
|
|
|
i have a folder inclodes some files
how can i read the file name from this folder
thankis for help
MD_NADA
|
|
|
|
|
You can use DirectoryInfo and FileInfo Class and then use getfiles method of directory ojbect to get all the files inside a particular directory. You can also use to to get a particular kind of file
DirectoryInfo dir = new DirectoryInfo(@"d:\skypak\text");<br />
FileInfo[] bmpfiles = dir.GetFiles("*.txt");
|
|
|
|
|
hello
how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user
thank you! hope that understand what i mean !!
|
|
|
|
|
Mahhouraaaaaa wrote: how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user
To explicitly raise an event in C# you just call the event as it were a method. You first must check to see if it is null. If it were null then there are no registered methods to that event and an exception will be thrown.
if(Clicked != null)
Clicked();
Your deal with the tab page control is more difficult. If I understood you correctly you want to fire an event of a control from the outside. You will have to send it the ?WM_MOUSECLICK? event, to do that you will need to inject that event into the message queue of Windows itself. You will need to use the native Windows API to do that. There may be other ways, but I am currently unaware of them.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
Hi.
How can I get the real time of a mp3 file in milisecond ?
Best wishes
|
|
|
|
|
I have to change some of my logic based on the error returned by a code. I have to first try to do a simple insert in a table. If it throws a error then i will have to change the statement(update) and again try the insert. How can i do this. Sorry if i hv posted the question in the wrong discussion board. It may be a quesiton of c# also
|
|
|
|
|
I assume that you expect an error because the record already exists? Then do it the other way arond; first try the update and check how many records were updated. If the record didn't exist the number of records is zero, and you know that you have to make an insert instead.
If you are using MS SQL Server, you can do this in a stored procedure:
create procedure DoSomeSetting
@SomeId int,
@SomeValue somedatatype
as
update DaTable
set Something = @SomeValue
where SomeId = @SomeId
if @@rowcount = 0 begin
insert into DaTable (Something)
values (@SomeValue)
end
---
b { font-weight: normal; }
|
|
|
|
|
hi
i have this code in VB and i want to Convert this code to C# but i don't know VB. Please Convert this code
To C# :
Dim nextLine As Int32
Call PrintGridHeaderLine(e)
Dim StartOfpage As Integer = _CurrentPrintGridLine
For nextLine = _CurrentPrintGridLine To Min((_CurrentPrintGridLine + RowsPerPage(_PrintFont,
e.Graphics)), CType(_DataGrid.DataSource, System.Data.DataTable).DefaultView.Count)
Call PrintGridLine(e, nextLine)
Next
Thanks ..
|
|
|
|
|
Int32 nextLine;
PrintGridHeaderLine(e);
int StartOfpage = _CurrentPrintGridLine;
for (int nextLine = _CurrentPrintGridLine; nextLine <= Min((_CurrentPrintGridLine + RowsPerPage(_PrintFont, e.Graphics)), ((System.Data.DataTable)(_DataGrid.DataSource)).DefaultView.Count); nextLine++) {
PrintGridLine(e, nextLine);
}
Aashutosh kumar
|
|
|
|
|
Hi,
I send mail thru C# code. During execution it throws
following error.
Unhandled Exception: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 of
fset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Sendmail.Main()
You only have to do a very few things right in your life so long as you don't do too many things wrong.
Vivek.S
|
|
|
|
|
IIS is installed in your PC or not. I think ,System.Net.Mail.SmtpClient.Send user virtual SMTP if you not specify Explicitly .
Check Virtual SMTP under IIS is running or not.If not then run Virtual SMTP.
Then you can send mail successfully.
Regards
rajesh
|
|
|
|
|
Wen is setted to = none you cant move it it all..
i wanna do like msn have..no matter where you click[except if its a component] the form can be moved
anyone knows?
|
|
|
|
|
set enable drag to true
create a variable in form class
bool draging
on mouse down event do
draging = true
on mouse up event do
draging = false
on mouse move event do
if(draging )
get mouse position every time save it to point vriable
check current postion with previous one
if they are not equal
change
this.position.x-=(point.x-e.mouseposition.x);
this.position.y-=(point.y-e.mouseposition.y);
and you are done
the above name of properties meathod may vary from actuals
i dont have c# ide this time
|
|
|
|
|
Amar Chaudhary wrote: i dont have c# ide this time
It's the logic that counts
|
|
|
|
|
I can't seem to figure out a way to loop over all cells in a DataGridViewColumn from within the column itself.
I have a class which extends the DataGridViewColumn class, and from within it I need to check all cell values in a way similar to:
foreach(DataGridViewCell cell in this.Cells){
// evaluate cell contents
}
Is there any property of the column I can use to achieve this? This functionality seems to be lacking from the column classes, though implemented in the row classes.
|
|
|
|
|
Hi all !
How can i access a specified field in 'Crystal Report'
eg: like how can i increase a value of a specified field of
'Crysatl Report'
Thanks bye
SalehMahmoud
|
|
|
|
|
Can anyone tell me where I can download OpenSource application that has been developed with modules?
Or a book to download with that topic - how to develop module oriented applications?
Thanks.
|
|
|
|
|
Just break your app into DLLs, surely ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|