|
how to pick n distinct (no repetition) strings randomly from an array of strings without using a while loop.
Any help appreciated.
Jad J.
|
|
|
|
|
wli ma7dood walla ma fhemna shi 3alayk.
n2ebir kttob meshkeltak metl el khale2 khalena nse3dak.
hehehehhe
yalla bye
jamil abou khalil
|
|
|
|
|
You might want to try your own homework first, and ask specific questions if you get stuck.
|
|
|
|
|
this[^] might help you. Search on Random
|
|
|
|
|
Hi,
I placed Gridview in my form and created boundfileds and template field. I placed Imagebuttons, hyperlinks in templatefield. I set the DataKeyNames property. After the grid is populated with some data, i want to show some tooltips when cursor is placed on the respective imagebutton and want to perform some task(like moving to next page based on the selectedrow datakeyname).
I was able to show the tooltip on mousehover. The code i worte is
protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)<br />
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{ <br />
ImageButton c1 = (ImageButton)e.Row.Cells[0].FindControl ("ctnBtn");<br />
if(c1 != null) <br />
{<br />
c1.Attributes.Add("onmouseover", "");<br />
c1.Attributes.Add("onmouseout", "");<br />
}<br />
}<br />
}
But not able to get the datakeyname of that particlar selected row.
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)<br />
{<br />
if (e.CommandName == "ctn")<br />
{<br />
string key = Gridview1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString();<br />
string url = "qwer.aspx?key="+key.ToString(); <br />
Response.Redirect(url);<br />
....<br />
}<br />
}
I was able to get the e.commandname correctly and gettig into the loop but was not getting the
e.CommandArgument of the selected row. It is showing the null everytime.
I was able to implement this rowcommand function correctly when the imagebutton control is not in the template field.
Let me know how to implement the Findcontrol method for <asp:buttonfield> of GridView
Let me know where i went wrong in implementing the code.
Thanks in Advance.
|
|
|
|
|
I want to create an xml and put it to a string. I noticed that XmlWriter always adds an xml header and an encoding="..." attribute to this header. This encoding attribute becomes erroneous if I save the string as a file with some other encoding. Is there a better way to skip this encoding attribute than the one below?
StringBuilder builder = new StringBuilder();
XmlWriter writer = XmlWriter.Create(builder);
writer.WriteStartDocument();
writer.Flush();
builder.Replace(" encoding=\"utf-16\"", "");
writer.WriteStartElement("foo");
writer.WriteStartElement("bar");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
return builder.ToString();
The result of this is:
<?xml version="1.0"?><foo><bar /></foo>
|
|
|
|
|
I found another, similar way, using XmlWriterSettings.OmitXmlDeclaration:
StringBuilder builder = new StringBuilder();
builder.Append("<?xml version=\"1.0\"?>");
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(builder, settings))
{
writer.WriteStartElement("foo");
writer.WriteStartElement("bar");
writer.WriteEndElement();
writer.WriteEndElement();
}
return builder.ToString();
|
|
|
|
|
hai all,
in c# is there any way to count the number of occurence of a specific character in a string?
my string is a,b,c,d,e,f
i need to count the number of commas in this string
All I ever wanted is what others have....
CrazySanker
|
|
|
|
|
hi,
u can use this code:
<br />
String str = "a,b,c,d,e,f";<br />
String []count = str.Split(',');<br />
int numOfOccurance = count.Length - 1;<br />
hope it helps
Jamil abou khalil
|
|
|
|
|
string x = "a,b,c,d,e,f";
int y = x.Split(',').Length - 1;
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Or:
Regex regex = new Regex( "," );
int count = regex.Matches( input ).Count;
----------------------------
Be excellent to each other
|
|
|
|
|
Easiest:
int cnt = str.Length - str.Replace(",", "").Length;
Fastest and most resource efficient:
int cnt = 0;<br />
foreach (char c in str) {<br />
if (c == ',') cnt++;<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I need to get some knowledge about the printing procedure in C# using VS 2005. I want to know how to use the print dialog and print document and any other necessarly object to print the text inside a text area (or multi-lined text box).
Thanks in advance;
jamil abou khalil
|
|
|
|
|
Hello
Did you revise the printing section in C# articles page?
Regards
|
|
|
|
|
hi,
I tried searching in the articles but i am not lucky to find anything.
If you can please point me to an article that may benefit me.
thanks
jamil abou khalil
|
|
|
|
|
I'm developing an Outlook Add-in with Visual Studio 2005 using COM.
I created a new project via Extensibility -> shared add-in, and I need to add the reference "Microsoft.Office.Interop.Outlook" in order to go on with the development. But it is no where to be found in the "Add Reference" Dialog Box.
Somebody help me, please......
|
|
|
|
|
I solved it myself...
The assembly is right there in:
COM -> Microsoft Outlook 11.0 Object Library......
|
|
|
|
|
I am creating a custom draw treeview with level 0 treenodes draw by the code below. I want to paint the entire node row, including behind the PlusMinus button with a color of choice.
The problem happens with my code running after the PlusMinus button is painted,thus erasing it. Is there some event fired before OnDrawNode painting the "+" that i am missing and should override?
Setting a breakpoint on the begining of OnDrawNode and seeing the control, shows me the "+" is already painted.
protected override void OnDrawNode(DrawTreeNodeEventArgs e){
if (e.Node.Level == 0){
Rectangle nodeRegion = new Rectangle(ClientRectangle.X, e.Node.Bounds.Y, ClientRectangle.Width, e.Node.Bounds.Height);
SolidBrush nodeBackColor = new SolidBrush(Color.BlanchedAlmond);
SolidBrush nodeForeColor = new SolidBrush(Color.Black);
Font nodeFont = (e.Node.NodeFont == null) ? this.Font : e.Node.NodeFont;
e.Graphics.FillRectangle(nodeBackColor, nodeRegion); // PROBLEM
e.Graphics.DrawString(e.Node.Text.Trim(), nodeFont, nodeForeColor, e.Node.Bounds.Location);
}
else{
e.DrawDefault = true;
}
base.OnDrawNode(e);
}
ps.: It looks like the OnPaint event isnt fired on a TreeView. Couldnt find why is this on MSDN.
Thanks!
Diego Valdevino
|
|
|
|
|
I have a UserControl and when Iam not using this.Region to form a custom shape for my UserControl everything is ok except that in the upper left and right corner you can see a cotrol background.
See here: http://img87.imageshack.us/my.php?image=goodjo2.jpg
When I put this piece of code:
region.Intersect(gp);
this.Region = region;
Where the gp looks like:
gp.AddArc(0, 0, 20, 20, 180, 90);
gp.AddArc(this.Width - 21, 0, 20, 20, 270, 90);
gp.AddLine(this.Width - 1, 20, this.Width - 1, this.Height - 1);
gp.AddLine(this.Width - 1, this.Height - 1, 0, this.Height - 1);
gp.CloseFigure();
In other words, those darker blue lines (borders) of the UC, I get this ugly looking corners in upper left and right corners and no right and bottom line.
See here: http://img291.imageshack.us/my.php?image=badid4.jpg
My question is, how can I set an Region to my UC without this 'stuff' around upper left and right corners and with right and bottom lines?
I hope you understand.
|
|
|
|
|
|
Hello,
I'm using Application.Exit(); in the form contructor to terminate the application if certain condition is met... but it's not working!
Why? and what can I do?
Thanks...
|
|
|
|
|
Hello
I believe you are making the famous scenario of checking a condition -maybe login or something- at the start of your application, if(false) => Exit(). Right?
Well if you take a look ate Program.cs file where the main method exists, you'd see this line
Application.Run(new MyForm());
So actually it excutes more like this:
MyForm temp = new MyForm()
Application.Run(temp)
Well, not exactly but I made it this way to illustrate that your constructor must return first before the Run() method actually gets called, and of course calling the Exit() method is useless if the Run() didn't get excuted first.
Suggested solution:
Simple; Make the Application.Exit() call in your Form_Load event if applicable.
Regards
|
|
|
|
|
|
Bad answer -- you can't Application.Exit() in Form_Load either. Only solution is change of architecture: don't start the form if you don't want to display it
|
|
|
|
|
Hello .
I am looking for a program or
an idea how to parse C# files .
What I mainly need to find is disposing of created objects in the methods
In each method in each class that is in the file ,
I want to look for object creation statement :
myObject = new CMyObject()
And then to see whether this object is disposed in the end of the method
( in the finally ) .
And I also want to analyze more stuff .
The question is whether anyone knows a program that can help me ,
or can give me an idea how to do it ?
CodeDom can help me ?
Is it possible to create CodeDom objects hierarhy from source code ?
Thanks
|
|
|
|