|
int myNumber = int.Parse(TextBox1.Text);
or
double myNumber = double.Parse(TextBox1.Text);
Just choose the right data type (int, float, double, ...). Then using method Parse.
|
|
|
|
|
Plz give me supar fast method for reading Large Xml File of 4MB to 10MB. i have used the following code but it is also slow for my Application.
1 st way->
FileStream sr=new FileStream ("C:\test.Xml",FileMode.Open);
XmlTextRader rd=new XmlTextReader(sr);
Whlie(rd.Read())
{
//
-----
//
}
Second way->
FileInfo sr=new FileInfo ("C:\Test.Xml");
XmlTextRader rd=new XmlTextReader(sr.OpenRead());
Whlie(rd.Read())
{
//
-----
//
}
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
How about :
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"C:\Test.Xml");
|
|
|
|
|
That is not faster at all.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Well the super-fast method would be read them same way as plain text. Maybe XML is not good format for your application? If you want to, provide more details about that XML file and app...
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Hello everyone,
I am trying to create a media player. Right now I would like to add a control panel with images representing "Play", "Pause", "Stop", etc. I am not sure what is the right way to go about this. I tried a "menuStrip" which was dokced to the button of my winform but that doesn't seem right.
I have come across "User Control" and I was wondering if this is the right way to get this done.
truly appriciate your help in this issue. Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Hi i have a form1 that allows user to search for words.
Then i have another form2 that is for displaying the results, taking into consideration the parameters from form1.
However i have errors telling me that the richTextBox1 that i'm using it in form2 is inaccessible due to its protection level.
Error 1 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 126 32 LookUpShakespeare
Error 2 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 127 32 LookUpShakespeare
Error 3 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 135 40 LookUpShakespeare
Error 4 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 136 40 LookUpShakespeare
Error 5 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 137 40 LookUpShakespeare
Error 6 'LookUpShakespeare.Form4.richTextBox1' is inaccessible due to its protection level G:\WebServices\Project\Projects\LookUpShakespeare\LookUpShakespeare\Form2.cs 138 40 LookUpShakespeare
Can anyone help me to solve this?
FORM1
using LookUpShakespeare.GoogleSvc;<br />
<br />
namespace LookUpShakespeare<br />
{<br />
public partial class Form2 : Form<br />
{<br />
public Form2()<br />
{<br />
InitializeComponent();<br />
}<br />
public TextBox t1 = new TextBox();<br />
public TextBox t2 = new TextBox();<br />
<br />
private void btnGenerate_Click(object sender, EventArgs e)<br />
{<br />
String buildTerm = "";<br />
if (radioButton5.Checked == true)<br />
buildTerm = word.Text;<br />
else<br />
buildTerm = "\"" + word.Text + "\"";<br />
<br />
if (radioButton2.Checked == true)<br />
buildTerm = "-" + buildTerm;<br />
<br />
if (txtSearchString.Text != "")<br />
if (radioButton4.Checked == true)<br />
buildTerm = " OR " + buildTerm;<br />
else<br />
buildTerm = " " + buildTerm;<br />
<br />
if (checkBox3.Checked == true)<br />
{<br />
<br />
t1.Text = "true";<br />
}<br />
else<br />
{<br />
t1.Text = "false";<br />
}<br />
<br />
if (checkBox4.Checked == true)<br />
{<br />
<br />
t2.Text = "true";<br />
}<br />
else<br />
{<br />
t2.Text = "false";<br />
}<br />
<br />
if (comboBox1.Text != "")<br />
{<br />
comboBox1.Text = comboBox1.SelectedItem.ToString();<br />
}<br />
else<br />
{<br />
comboBox1.Text = "English";<br />
}<br />
<br />
if (word.Text != "")<br />
{<br />
txtSearchString.Text += buildTerm;<br />
buildTerm = "";<br />
word.Text = "";<br />
groupBox3.Enabled = true;<br />
} <br />
}<br />
<br />
public int beginResultPage = 0;<br />
public string q, combo;<br />
public Boolean f, s;<br />
<br />
private void btnSearch_Click(object sender, EventArgs e)<br />
{<br />
GoogleSearchService gsearch = new GoogleSearchService(); <br />
GoogleSearchResult gresult = new GoogleSearchResult();<br />
try<br />
{<br />
q = this.txtSearchString.Text;<br />
f = Convert.ToBoolean(this.t1.Text);<br />
s = Convert.ToBoolean(this.t2.Text);<br />
combo = this.comboBox1.Text;<br />
showResults(this.beginResultPage, this.key.Text, q, f, s, combo);<br />
<br />
}<br />
catch (System.Web.Services.Protocols.SoapException ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
private void showResults(int beginResultPage, string key, string q, Boolean f, Boolean s, string combo)<br />
{<br />
GoogleSearchService gsearch = new GoogleSearchService();<br />
GoogleSearchResult gresult = new GoogleSearchResult();<br />
try<br />
{<br />
gresult = gsearch.doGoogleSearch(key, q, beginResultPage, 10, f, "", s, combo, "", "");<br />
Form4 ResultForm = new Form4();<br />
ResultForm.SearchForm = this;<br />
ResultForm.Text = "Estimated Result Count: " + gresult.estimatedTotalResultsCount.ToString();<br />
int j = gresult.resultElements.Length;<br />
ResultForm.elementCount = j;<br />
if (j == 0)<br />
<pre>{<br />
ResultForm.<big>richTextBox1</big>.Text += "Google Search results: " + "\r";<br />
ResultForm.<big>richTextBox1</big>.Text += "Sorry, no search results to display!";<br />
}</pre> else<br />
{<br />
for (int i = 0; i < j; i++)<br />
{<br />
if (gresult.resultElements[i] != null)<br />
<pre>{<br />
ResultForm.<big>richTextBox1</big>.Text += "Return Result # " + (beginResultPage + i + 1).ToString() + "\r";<br />
ResultForm.<big>richTextBox1</big>.Text += gresult.resultElements[i].title + "\r";<br />
ResultForm.<big>richTextBox1</big>.Text += gresult.resultElements[i].snippet + "\r";<br />
ResultForm.<big>richTextBox1</big>.Text += gresult.resultElements[i].URL + "\r\r";<br />
}</pre> }<br />
}<br />
ResultForm.Show();<br />
}<br />
catch (System.Web.Services.Protocols.SoapException ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
<br />
}<br />
}
FORM2
using LookUpShakespeare.GoogleSvc;<br />
<br />
namespace LookUpShakespeare<br />
{<br />
public partial class Form4 : Form<br />
{<br />
public Form4()<br />
{<br />
InitializeComponent();<br />
}<br />
public Form2 SearchForm;<br />
public int elementCount = 0;<br />
<br />
<br />
<br />
}<br />
}
Regards, frossie
|
|
|
|
|
Why not simply using delegates?
|
|
|
|
|
I'm having difficulty adding hidden text to a RichTextBox. See case2 below.
Case1:
Initialize Form1 in Main(string[] args){}.
In Form1, initialize a RichTextBox as follows:
RichTextBox rtb = new RichTextBox();
Observe that rtb.SelectedRtf is initially set to "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n";
Now try:
rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}";
result:
rtb.Text = "visibleTexthiddenText" as expected.
Case2:
Form1 is initialized as an MDIChild Form:
Again in Form1, initialize a RichTextBox as follows:
RichTextBox rtb = new RichTextBox();
This time rtb.SelectedRtf is initially set to empty string.
Try:
rtb.SelectedRtf = @"{\rtf1\ansi " + "visibleText" + @"\v " + "hiddenText" + @"\v0}";
result:
rtb.Text = "visibleText"
i.e. the hidden text is not being updated when Form1 is an MDIChild.
Anyone know the cause/walkaround? Your help is appreciated.
Thanks, B
|
|
|
|
|
I am facing the same issue. Its been 5 years since you have asked this question. Did you get the solution ? If so, please share with me.
|
|
|
|
|
As I recall an external component was loading a different version of the riched32.dll/riched20dll. Workaround was to initialize the right dll first (new RichTextBox() in your application).
Hope this helps.
|
|
|
|
|
Thank you very much for responding. I will give a try. Thanks again !
|
|
|
|
|
Hello,
I have an application names "Control Center". In this application i have implemented
Socket Server. I starts any number of .exe of my other application through process start.
And in that application i have implemented Socket client.
Now, i want suggestion that,
1.Is it good to communicate clients and server on single port?.
2. Is it harmfull to keep socket connection open continuously?.
3.If, i keep socket connection open continuously will it work properly?.
Please guide me.
Thanks In Advance.
Rahul Kulkarni
|
|
|
|
|
hi all
my requirement is like this on updation of table on the webserver an event should rise and let someone on the server should knwo that.....
i want a good site where i can get info. relating this or any suggestions how to do this....
how can i catcht the event tat is rised in sql server .... in vs 2005
thank you in advance
byebye
|
|
|
|
|
If you perform an update, you can catch this with a trigger. How you want to proceed beyond this, is entirely up to you, but I would start with defining a trigger.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want to know how to reduce the color depth of a Bit Map Image in c#.
Then the resolution will be less at the same time the capacity of the image also will be reduced.
Then it is easy to send the image throght network due to the low capacity.
Hope thee will be some one who can give me a clue.
Thank You
NRKumudunee
|
|
|
|
|
Hi, I have a web method that is very chatty, here is sample output from it;
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<types:MyWebMethodResponse>
<MyWebMethodResult href="#id1"/>
</types:MyWebMethodResponse>
<soapenc:Array soapenc:arrayType="types:MyType[1]" id="id1">
<Item href="#id2"/>
</soapenc:Array>
<types:MyType id="id2" xsi:type="types:MyType">
<Id xsi:type="xsd:string">someid</Id>
<Number xsi:type="xsd:string">Number 1</Number>
<Title xsi:type="xsd:string">Title</Title>
<Addr xsi:type="xsd:string">some address</Addr>
<City xsi:type="xsd:string">some city</City>
<State xsi:type="xsd:string">some state</State>
<Zip xsi:type="xsd:string">11111</Zip>
<Times href="#id3"/>
</types:MyType>
<soapenc:Array soapenc:arrayType="types:Time[256]" id="id3">
<Item href="#id5"/>
<Item href="#id6"/>
<Item href="#id7"/>
<Item href="#id8"/>
<Item href="#id9"/>
...
<Item href="#id258"/>
<Item href="#id259"/>
<Item href="#id260"/>
</soapenc:Array>
<types:Time id="id5" xsi:type="types:Time">
<StartTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</StartTime>
<EndTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</EndTime>
</types:Time>
<types:Time id="id260" xsi:type="types:Time">
<StartTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</StartTime>
<EndTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</EndTime>
</types:Time>
</soap:Body>
</soap:Envelope>
All of those <Item href...> take up a lot of space, is there a way instruct .net not generate it?
This is the declaration over the webservice C# class file;
[WebService(Namespace=Constants.NAMESPACE), ToolboxItem(false), SoapRpcService]
The web method just has plain, [WebMethod] attribute and that's it.
Thanks,
|
|
|
|
|
I had posted this question two weeks back but till date no one has responed. Is this indeed an issue with the combobox? I hope I'm clear with my question and this time I will get some help from this forum.
ComboBox control has got selectedindexchanged event. As the name suggest this event should fire when selected item change for the combobox. But this event fires even when the currently selected item is selected again from the dropdown list of combobox.
e.g.
if I have loaded following items in my combobox say
item1
item2
item3
item4
with item1 as selected when my application starts.
Now if from UI, I again select the "item1" (which is already selected in combo box) then also the selectedindexchanged event fires. In this case the index has not changed still the selectedindexchanged event fires. I find this bit strange.
Is there anyway to findout when the selected item has changed by User. I want some kind of notification when user indeed changes the combobox selected item (not when combobox.selecteditem is set through code)?
regards
KC
|
|
|
|
|
You have to store your selected index, and compare it to what is in the control after the event fires. The event should check first, then store the value for next time.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian
Thanks for your reply. I agree to your solution where I have to remember the previously selected index and match it with the newly selected index in the eventhandler. If new and previous indexes are same then skip the execution of handler. But this is not going to serve my purpose.
What I want is, I want to skip the execution of ComboboxSelectedIndexChanged Eventhandler when the already selected item in the combobox is again selected by user (i.e. user clicks the combobox and select the same item again). I don't mind if combobox SelectedIndex changed event fires through some code i.e. ComboBox.SelectedIndex = 2;
So in nutshell want to restrict the eventhandler when same item is selected through user interaction.
|
|
|
|
|
Well, you plainly can't stop the event from firing. Until it fires, you can't make your code run at all.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You could combine it with TextChanged event
|
|
|
|
|
Try overriding the combobox control. Very, very basic example below;
class ComboBoxWidget: System.Windows.Forms.ComboBox
{
#region private member variables
private int _selectedIndex = -1;
#endregion
#region overrides
protected override void OnSelectedIndexChanged( EventArgs e )
{
if( this.SelectedIndex != this._selectedIndex )
{
this._selectedIndex = this.SelectedIndex;
base.OnSelectedIndexChanged( e );
}
}
public override int SelectedIndex
{
get
{
return base.SelectedIndex;
}
set
{
this._selectedIndex = value;
base.SelectedIndex = this._selectedIndex;
}
}
#endregion
}
|
|
|
|
|
How to call .mht files in C# project?
|
|
|
|
|
What is an mht file ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|