|
i am having a string ,say"14p"....I want to take only the value 14 so that i could convert that to integer..how can i achieve this?
|
|
|
|
|
n i want to split that string on occurence of any alphabets
|
|
|
|
|
hi, I did this using regular expressions. I wrote a method to split a string by alphabetic characters.
14p gives array of one item 14
14eur gives an array of one item 14
14eur14pp15p gives an array of 3 items 14, 14, and 15
http://pastebin.com/f55499ed[^]
modified on Wednesday, December 30, 2009 2:56 AM
|
|
|
|
|
how about this -
public String[] Split(String alpha)
{
String str = alpha;
List<String> returnVal = new List<String>();
Regex regexp = new Regex("[0-9]+");
MatchCollection matchColection = regexp.Matches(str);
for (int i = 0; i < matchColection.Count; i++)
{
returnVal.Add(matchColection[i].Value);
}
return returnVal.ToArray();
}
Modified Split function[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Assume that your input string like:
Input: a1f2g3r46mj5kde6
Output:123456
I think at first you split it in to an array and pass each array item to a function for numeric validation. That.s It...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I got InvalidComObjectException on exit on release build application. If I don't use RichTextBox, I don't see crash. In debug build application, I also don't see crash. On some release machine, even if I call CurrentDispather.InvokeShutdown won't eliminate crash.
My main appliation is a unmanaged MFC. The WPF control is embedded in CView in this MFC application.
Any idea or suggestion? Thanks.
|
|
|
|
|
I am currently using ControlPain.DrawBorder. it has 2 overloades.
DrawBorder(Graphics, Rectangle, Color, Int32, ButtonBorderStyle,
Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle,
Color, Int32, ButtonBorderStyle)
DrawBorder(Graphics, Rectangle, Color, ButtonBorderStyle)
With first overload, each size can be set a line width. However the second overload it doesn't. Is this a always constant? if not how can I programaticly acquire this info?
|
|
|
|
|
|
Thanks, that is just what i needed
|
|
|
|
|
I am hosting WPF components in unmanaged MFC. This WPF components will do some ricktext editing. Hosting / editing are working fine but closing will crash application on exit (release version only and no crash on debug). The following is the current structure:
class parentA_COM : definited / implemented in unmanaged C++, STA
class memberB_COM : definited in unmanaged C++, but implemented in C# (ComVisible)
class winUserControl: implemented in C# to host WPF user control;
class wpfUserControl: implemented in C#
class MyApp // unmanaged C++
{
main ()
{
parentA_COM pPA(); // Initialize COM component
}
}
class parentA_COM // unmanaged C++
{
void get_hWnd()
{
m_ipMB.CreateInstance(xxx);
m_ipMB->get_hWnd();
}
private:
memberB_COM m_ipMB;
}
class memberB_COM : IDisposable, ... // C#
{
constuctor // initialize winUserControl
}
class winUserControl : UserControl
{
host WPF control wpfUserControl
}
How can I mark / make wpfUserControl / or winUserControl / or memberB_COM STA? Thanks.
|
|
|
|
|
Hi,
i'm "new" here and try to learn a little c#.NET
So for train a little i thought to write a software, copy a string into the search field of this page: http://www.dict.cc/[^]
After that the software should press the search button and list the items. would be enougth if someone of you can tell me how it works... i already started:
WebBrowser wb = new WebBrowser();
wb.Url = new Uri("http://dict.cc/");
HtmlDocument htmldoc = wb.Document;
// <input name="s" id="sinp" maxlength="100" size="25" style="padding: 2px; width: 340px;" value="" type="text">
htmldoc.All["sinp"].InnerText += richTextBox1.Text;
// <input id="submit" value="Suche" class="inp1" style="padding: 1px;" type="submit">
htmldoc.All["submit"].InvokeMember("Click");
this does not work, i always get the following error for the last 2 lines: "NullReferenceException was unhandled"
and i don't know how to go on... so wait for the response and read the first answer..
|
|
|
|
|
WRONG FORUM
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
CAN YOU TELL ME WHERE I CAN POST ?
|
|
|
|
|
|
Ok, i think you missunderstood something.
The page already exists and i want to write a Windows Forms Application in C#.
I never worked with the NET libraries of .NET before and i've read a lot and tried to start. And as OriginalGriff told me to debug, i've already done...
I found an article with "How to login to gmx with C#" and i start to build.
I just want to know how to use the WebBrowser without using it as controle, how to fill fields, press buttons and wait for an response. I hoped that you can give me some usefull links with some explanations or some open source software to read and rewrite.
|
|
|
|
|
Hi,
if you don't want a user to interact with a WebBrowser Control, then you should not use one.
Use HttpRequest and HttpResponse classes instead.
|
|
|
|
|
There are a lot of things in your code which could be causing this, and the best way to help you is not for me to guess! You need to learn how to debug this - you will be doing this a lot, so learn now.
Put a break point on the line "WebBrowser wb = new WebBrowser();" and run your program in the debugger. When it stops on the line, use the single step ("Step Into") button on you toolbar to follow the code through. Check before you execute what the contents of each variable are - you will soon find the null reference.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I am iterating through all of the bookmarks in a word document.
I am able to retrieve the bookmark names, but unsure how to retrieve the bookmark values?
Here's a code snippet that I'm using to get the bookmark names and it's working great, but I also
need to get the value (text) for each bookmark.
Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(... arguments...);
doc.Activate();
for (int i = 1; i <= doc.Bookmarks.Count; i++)
{
object bkmk = i;
MessageBox.Show("Bk: " + doc.Bookmarks.get_Item(ref bkmk).Name);
}
Thanks for any help.
|
|
|
|
|
Maybe this will work for you:
string value = doc.Bookmarks.get_Item(ref bkmk).Range.Text;
|
|
|
|
|
Hi. I would like to be able to bring up another form for editing data in Detail view when click on a row in gridview. these or the code that i'm workin with but don't seem to be working. Anyone help me or show me another easier way to do it
// EmployeesViewForm.cs ////This the GridviewForm
class EmployeesViewForm : Form {
...
void addToolStripButton_Click(object sender, EventArgs e) {
this.EditEmployee(this.employeesBindingSource.AddNew());
}
void updateToolStripButton_Click(object sender, EventArgs e) {
this.EditEmployee((DataRowView)this.employeesBindingSource.Current);
}
void EditEmployee(DataRowView item) {
// Pass to child employee details form
EmployeesEditForm dlg = new EmployeesEditForm(item);
if( dlg.ShowDialog() == DialogResult.OK ) {
// Reset to reflect changes automatically
this.employeesBindingSource.ResetCurrentItem()
}
}
// EmployeesEditForm.cs
// EmployeesEditForm.cs //// This the form with detail View
partial class EmployeesEditForm : Form {
...
void EmployeeItemForm_FormClosing(
object sender, FormClosingEventArgs e) {
// Cancel edit if Cancel button is pressed or form is closed from
// either the system menu or close box
if( (e.CloseReason == CloseReason.UserClosing) ||
(this.DialogResult == DialogResult.Cancel) ) {
this.employeesBindingSource.CancelEdit();
}
}
}
|
|
|
|
|
Well, Sparky, we can't read it because it's not formatted properly.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
<big> <br />
class EmployeesViewForm : Form <br />
{<br />
<br />
void addToolStripButton_Click(object sender, EventArgs e) <br />
{<br />
this.EditEmployee(this.employeesBindingSource.AddNew());<br />
}<br />
<br />
void updateToolStripButton_Click(object sender, EventArgs e) <br />
{<br />
this.EditEmployee((DataRowView)this.employeesBindingSource.Current);<br />
}<br />
<br />
void EditEmployee(DataRowView item) <br />
{<br />
EmployeesEditForm dlg = new EmployeesEditForm(item);<br />
if( dlg.ShowDialog() == DialogResult.OK ) <br />
{<br />
this.employeesBindingSource.ResetCurrentItem()<br />
}<br />
}<br />
<br />
<br />
<big> partial class EmployeesEditForm : Form <br />
{<br />
<br />
void EmployeeItemForm_FormClosing(<br />
object sender, FormClosingEventArgs e) <br />
{<br />
if( (e.CloseReason == CloseReason.UserClosing) ||<br />
(this.DialogResult == DialogResult.Cancel) ) {<br />
this.employeesBindingSource.CancelEdit();<br />
}<br />
}<br />
<br />
<br />
<br />
<big><br />
partial class EmployeesEditForm : Form <br />
{<br />
<br />
public EmployeeItemForm(object item) <br />
{<br />
<br />
if( (item is DataRowView) &&<br />
(((DataRowView)item).Row is NorthwindDataSet.EmployeesRow) ) <br />
{<br />
InitializeComponent();<br />
<br />
this.employeesBindingSource.DataSource = item;<br />
}<br />
else throw new ArgumentException("Incorrect type");<br />
}<br />
<br />
}
|
|
|
|
|
I'm trying to implement a checkbox in a DataGridView in a WinForms app. I am creating the DataTable, then binding it to the DataGridView:
DataTable table = new DataTable();
table.Columns.Add("ColumnId", typeof(int));
table.Columns.Add("QueryId", typeof(int));
table.Columns.Add("TableId", typeof(int));
table.Columns.Add("TableName", typeof(string));
table.Columns.Add("ApexColumnName", typeof(string));
table.Columns.Add("Expression", typeof(string));
table.Columns.Add("MyCheckBox", typeof(bool));
dsGrid.Tables.Add(table);
grdData.DataMember = dsGrid.Tables[0].TableName;
grdData.DataSource = dsGrid.Tables[0];
The checkbox column appears, but when I add a row, the check the checkbox, nothing happens. No checkbox appears.
Everything makes sense in someone's mind
|
|
|
|
|
The ReadOnly property on that column is probably set to true.
|
|
|
|
|
I set it to true, and no change.
When a checkbox is set to true in code, and cannot be unchecked when run
Everything makes sense in someone's mind
|
|
|
|