[C#] Displaying a clickable list?
Hey guys, at the moment I am trying to code an Instant Messenger which up until now has gone great (working chat, working display pictures etc) but at the moment I am stuck with the friends list. Basically what needs to happen is that the code needs to get from the MySQL a list of all the persons friends and then it needs to display them on the form and also each friend needs to be clickable like on msn so when they click the friend a convo with that particular friend begins... Is this even possible with c# and windows forms? If it is I would be very greatfull for you help with this issue.
Thanks guys!
Re: [C#] Displaying a clickable list?
You mean like a menu thingy?
Re: [C#] Displaying a clickable list?
Re: [C#] Displaying a clickable list?
Sure, thats easy.
Go to the event handlers with listview selected (looks like a lightning) and add a eventhandler for eg mousedoubleclick.
Anything is possible :)
Re: [C#] Displaying a clickable list?
Quote:
Originally Posted by
Aurora
Sure, thats easy.
Go to the event handlers with listview selected (looks like a lightning) and add a eventhandler for eg mousedoubleclick.
Anything is possible :)
But wouldn't that make an event for double clicking the box now the items in the listview? Is there a better way to do this without a listbox? Cause every friend from the db has to have a piece of code auto written for it to open the chat window with the client?
Re: [C#] Displaying a clickable list?
i guess you can use a datagridview.
and then just remove header display, and so forth (set it how you want it to look).
then simply add a CellContentMouseDoubleClick event handler.
thats how i usually go about it anyways, also if you wish to include things like sorting and such later :)
Re: [C#] Displaying a clickable list?
Hmm, I think I may have a solution. Also, one off topic question because im generating a random login key I need to check if the data already exists in the database and if it does it needs to generate another key...
this is what I have so far
Code:
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(10000000, 9999999999);
}
all it does so far is generate a random number between the min and max.
any idea how I could do it?
Re: [C#] Displaying a clickable list?
Random random = new Random();
private int RandomNumber()
{
return random.Next(10000000, int.max);
}
is better and more safe :)
i dont see what more you would need ?
Re: [C#] Displaying a clickable list?
Quote:
Originally Posted by
Aurora
Random random = new Random();
private int RandomNumber()
{
return random.Next(10000000, int.max);
}
is better and more safe :)
i dont see what more you would need ?
I need it to check to see if the number generated already exists in the database and if it does then it will select another key
Also, it would be better if there could be a mix of letters and numbers for exampe a key might be: AHHASH56456
Re: [C#] Displaying a clickable list?
for db thing you just do a query when you have the random number.
(psudo code)
select * from tablename where randomkey='+mynewkey+'
if it returns a table, its already there, then generate a new key and check again.
about numbers an letters, took about 3 seconds on google with "generate random ascii char c#"
http://www.obviex.com/Samples/Password.aspx
Re: [C#] Displaying a clickable list?
Thanks a lot =]
Stupid of me not to think about the password check o_O *isnoob* rofl