|
You are aware that people help out here for free aren't you? Please read this[^] article for the etiquette in the forums.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hmmm. Please don't do this. You didn't even allow 2 minutes before posting the question in a different forum. Never, ever, do this again.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I know that there are two .net extended generics libraries: PowerCollections and C5
I want to use one of them.
but I do not know which one is better to use, from the viewpoint of powerfulness and reliability.
I hope someone who has already experience in using them can give some suggestions and hints.
thanks.
|
|
|
|
|
Personally I've only ever used PowerCollections, and it's been perfectly reliable.
They aren't mutually exclusive, you can use both in one project.
My advice would be only use them when you have a requirement for something specifically more complex than the inbuilt collections, don't just use them for the sake of it.
For example - We identified the need for a complex dictionary containing items indexed in two ways. We looked at the available options and considered writing it ourselves. After review, the PowerCollections MultiDictionary fitted our requirements so we used that. We don't just use PowerCollections for everything though.
Simon
|
|
|
|
|
Hi,
I'm running visual studio 2005 C#, I need to auto-resize a datagrid when I maximize the windows form. How can I do this, can anyone help.
Thanks
Mbulelo
|
|
|
|
|
Hi
There is Property call Dock in datagridview. Set the Dock Property to Fill.
|
|
|
|
|
If you don't want to fill in whole container, use the Anchor property.
!alien!
|
|
|
|
|
Hi,
I want to implement the Exist() method for ObservableCollection, which is already available in the List collection.
Can anyone please guide me to implement the exact method implementation of the same?
Regards,
- K (http://kunal2383.blogspot.com)
|
|
|
|
|
For simple types you could always use this as an extension method:
public static bool Exists<T>(this ObservableCollection<T> collection, T value)
{
var list = (from p in collection
where p.ToString() == value.ToString()
select true).FirstOrDefault();
return list;
} This isn't guaranteed to work with complex types due to its reliance on the ToString operations.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
This is quite ok. But I need to pass a delegate there like:
collection.Exists(delegate(Person p) { return p.Id.ToLower().Equals(data.Id.ToLower()); })
Any idea?
Regards,
- K (http://kunal2383.blogspot.com)
|
|
|
|
|
Use reflector to take a look at how Exists is implemented on List .
It uses a method called FindIndex, which you can also look at.
It's pretty simple. It checks some preconditions and throws various argument exceptions, but the main part of the code is just a for loop calling the passed in predicate on each item.
public bool Exists(Predicate<T> match)
{
return (this.FindIndex(match) != -1);
}
public int FindIndex(Predicate<T> match)
{
return this.FindIndex(0, this._size, match);
}
public int FindIndex(int startIndex, Predicate<T> match)
{
return this.FindIndex(startIndex, this._size - startIndex, match);
}
public int FindIndex(int startIndex, int count, Predicate<T> match)
{
if (startIndex > this._size)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
}
if ((count < 0) || (startIndex > (this._size - count)))
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
}
if (match == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
int num = startIndex + count;
for (int i = startIndex; i < num; i++)
{
if (match(this._items[i]))
{
return i;
}
}
return -1;
}
Simon
|
|
|
|
|
Thanks ... this resolved my problem...
Regards,
- K (http://kunal2383.blogspot.com)
|
|
|
|
|
Hi all
I’m having 2 problems in C# now.
1. I have a MDIParent form which loads the login form in the form_load event. From there I if the user login successfully, I want to enable all menu items on the menu bar. If the login is fail, I want to disable some menu items there too. This means I want to enable/disable a MdiParent’s element from a child form, please help me how to do that.
2. From question 1, when I want to open a form from the menu, I create an object then just show it like this.
frmCustomer frmCus=new frmCustomer();
frmCus.MdiParent=this;
frmCus.Show();
But the problem is while a Customer form is opening, when the Customer menu is clicked, it creates another Customer form for me. Is there any way to check weather the form is shown or not before showing it?
|
|
|
|
|
You need to pass the current instance of your parent form to the LoginForm. This way:
LoginForm frmLogin = new LoginForm(this);
While the constructor for LoginForm will be:
public LoginForm(MDIparent frmParent)
{
this.Parent=frmParent;
}
This way you will be able to access all the controls of the parent form.
For your second problem, Application.OpenForms collection is there to help you. If the CustomerForm is already in the collection, just set Focus to it, otherwise create a new instance of it and show.
|
|
|
|
|
Thank you for your quick reply. It's very helpful for me, but can you give me more where to put Application.OpenForms in?
|
|
|
|
|
Inside the CustomerMenu click event.
ClickEvent:
if CustomerForm is open:
just set the focus on it
else:
Create it
End
|
|
|
|
|
I got it, thank you very much.
|
|
|
|
|
How to delete the URL from cache entry in c#?
While navigating in IE, consider You had open
(1) http://www.google.co.in/ in the browser(IE)
and then You had opened gmail account
(2) https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fhl%3Den%26tab%3Dwm%26ui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&scc=1<mpl=default<mplcache=2&hl=en
and then consider You had opened
(3) http://in.yahoo.com/?p=us
in same window.
After all, If you the generally click the back button when (3) is opened, it navigates to gmail account (i.e., (2) ),
but I want the navigation should be done from (3) to (1) by clicking 'back' button.
How can I achieve this,
If I delete the URLCacheEntry, can it be achieved?
I have to do this in c#,
So I i imported the WinInet funtion from http://msdn.microsoft.com/en-us/library/aa383983(VS.85).aspx
it doesn't show any effect,
Is there any other way to achieve this?
|
|
|
|
|
help me to validate DataGridView coloumn to take only float values.
|
|
|
|
|
You mean the user can enter only numeric value cannot enter text ?
|
|
|
|
|
yes,column should allow user to enter only float values.
|
|
|
|
|
I am using the C# API to insert a xml file which is having schemaLocation attribute in it.
from the database side, we are using ODP.Net provider for oracle 10g.
ODP.Net is having full support in case of xml native functionalities and we are using non-structured xml type of storage.
Problem:
"Open cursors exceeded" exception is coming when importing more than 300 xml files into xmltype(Oracle) field with ODP.Net provider(Oracle.DataAccess.dll) using the relevant C# API for that.(I have Disposed all the resources using here).
here is the sample code:
string strFileContents = strXmlRecordContent;
if (Conn == null)
{
Conn = new Oracle.DataAccess.Client.OracleConnection(CatalogueDbConnection.ConnectionString);
}
if (Conn.State != ConnectionState.Open)
{
Conn.Open();
}
Oracle.DataAccess.Client.OracleCommand cmdInsertXmlRec = new Oracle.DataAccess.Client.OracleCommand();
cmdInsertXmlRec.Connection = Conn;
cmdInsertXmlRec.CommandText = "INSERT INTO XMLRecord (MetadataID,XMLData) VALUES(:Metadataid,:strFileContents ) ";
cmdInsertXmlRec.Parameters.Add(":Metadataid", Oracle.DataAccess.Client.OracleDbType.Int32).Value = MetadataID;
OracleXmlType Text = new OracleXmlType(Conn, doc);
cmdInsertXmlRec.Parameters.Add(":strFileContents", Oracle.DataAccess.Client.OracleDbType.XmlType).Value = Text;
cmdInsertXmlRec.ExecuteNonQuery();
if (cmdInsertXmlRec != null)
cmdInsertXmlRec.Dispose();
one main observation: cursors are opened if the xml file is having schemaLoaction attribute in it.
|
|
|
|
|
Hello. I was wondering, Im working on a TCP Server. How would I do the follow?
1.) When a client types something in the console, and its sent to the server, how would I parse that and do like an if(data == "hello") { blah blah }. How would I be able to parse the recieved string. If someone could help me I would GREATLY appreciate it. Here is my current server:
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class UdpSrvrSample
{
public static void Main()
{
byte[] data = new byte[1024];
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 7557);
UdpClient newsock = new UdpClient(ipep);
Console.WriteLine("Waiting for a client...");
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
data = newsock.Receive(ref sender);
Console.WriteLine("Connection received from {0}", sender.ToString());
string welcome = "OpticVPS Remote Administration";
data = Encoding.ASCII.GetBytes(welcome);
newsock.Send(data, data.Length, sender);
while (true)
{
data = newsock.Receive(ref sender);
Console.WriteLine(Encoding.ASCII.GetString(data, 0, data.Length));
newsock.Send(data, data.Length, sender);
}
}
}
[X] 100% HTML
[ ] 100% PHP
[ ] 100% C#
|
|
|
|
|
Seriously?
The snippet you posted shows you how to make a string from a byte array.
|
|
|
|
|
Hi all,
How can I check for past or future date. I've a DateTime value and I want to know it's either past date or a future date from the current DateTime. Can you someone help me to do this.
Thanks.
I appreciate your help all the time...
CodingLover
|
|
|
|