I am using C# and Visual Studio. I have a ListBox full of names and a TextBox above it that I want to use to search the ListBox. I am trying to set it up so as I type in the search box it will remove any items in the ListBox that do not match what I am typing. I got the "as I am typing" part to work but have totally screwed the searching part. Here is my most likely terrible and redundant code:
[CODE] private void textBoxSearchPlayer_TextChanged(object sender, EventArgs e)
{
for (int i = listBoxPlayersList.Items.Count - 1; i >= 0; i--)
{
if (!listBoxPlayersList.Items.Contains(listBoxPlayersList.FindString(textBoxSearchPlayer.Text.ToLower().ToString())))
{
listBoxPlayersList.Items.RemoveAt(i);
}
else if (listBoxPlayersList.Items.Count == -1)
{
MessageBox.Show("No matching names found.");
UpdatePlayerList();
return;
}
else
{
UpdatePlayerList();
return;
}
}
}[/CODE]
From what I understand the [CODE]listBoxPlayersList.FindString[/CODE] should be able to search for partial words. Is there something else I should use or am I using it wrong? I really don't want to have to type the name in exactly to find it. I want the list to shrink as I type, based on what I am typing. Any help would be greatly appreciated.
[QUOTE=Wyzard;46907053]You haven't provided much detail on what you want your application to do, but a communications application is likely to be [url=https://en.wikipedia.org/wiki/I/O_bound]I/O-bound[/url], not [url=https://en.wikipedia.org/wiki/CPU-bound]CPU-bound[/url]: your program will probably spend most of its time waiting for data from the network.
Well-written C++ can be faster than code written in higher-level languages, but it's not guaranteed (you have to know what you're doing, and it may involve a lot of optimization work), and it's unlikely to make a noticeable difference for a program that isn't CPU-bound. Higher-level languages, on the other hand, can be easier to work with and may provide higher-level networking-abstractions out-of-the-box. (The C++ standard has no networking facilities, so you'll either have to find a third-party library or use platform-specific raw sockets, which is tedious.)
Write your program in C++ if you like C++, but don't assume that you [i]need[/i] to use C++ or your program will be too slow. Plenty of successful network applications are written in Java, Python, and even JavaScript (to name a few). Go with whatever language will be most convenient and enjoyable to work with.[/QUOTE]
Thank you for your input. It will basically be an IRC client with a few additional features besides text-based chat. I've been noticing that it may be difficult to use C++ for this (the exact reason you stated) so I may try Python instead. While I would like to use C++, I feel like I would be more motivated to complete it using Python because it wouldn't be so abstract for a beginner.
[editline]12th January 2015[/editline]
Yeah, I think I'm gonna use Python. Time to find out how to build an irc client/server.
[t]http://i.imgur.com/qf4GZnV.jpg[/t]
So I have a problem and I know why it's happening but not sure how to fix it. Basically if you compare the scenes, the hand bone rotations aren't exactly the same. I figured out this was because I used local rotation mode in 3ds max. If I rotate the bones from 0,0,0 with global rotation mode, it works correctly. However doing animations with the global mode is kinda hard, so does anyone know if it's somehow possible to convert local rotation mode angles to global rotation?
How would I get into creating a game with C++? I'm slowly trying to learn the language and I've just been using the command prompt to test things. How can I create a window that isn't the console and draw things to it?
You use a library like SFML.
[QUOTE=ThePuska;46913828]You use a library like SFML.[/QUOTE]
Is there a library that's better than another or is all preference? Like, is there a major difference between OpenGL, SFML, and SDL?
[QUOTE=All0utWar;46913933]Is there a library that's better than another or is all preference? Like, is there a major difference between OpenGL, SFML, and SDL?[/QUOTE]
Yes. One is a driver-implemented Open Graphics Library that SFML and SDL may make use of. The others are frameworks for interactive application creation, such as games.
SFML is higher level and provides more abstractions. SDL is lower-level.
Is there anywhere I can practise refactoring and things like that?
Have a final part of an interview coming up and I it's a coding test where I'm going to have to refactor bad code.
Just wondering if there is a good place to practise it.
[QUOTE=Over-Run;46918122]Is there anywhere I can practise refactoring and things like that?
Have a final part of an interview coming up and I it's a coding test where I'm going to have to refactor bad code.
Just wondering if there is a good place to practise it.[/QUOTE]
To be honest refactoring your own projects is probably the best practice you could get. Unfortunately that doesn't really answer your question
[QUOTE=Over-Run;46918122]Is there anywhere I can practise refactoring and things like that?
Have a final part of an interview coming up and I it's a coding test where I'm going to have to refactor bad code.
Just wondering if there is a good place to practise it.[/QUOTE]
I'm not sure where you'd look for projects other than your own ones, but a good place to start with refactoring is learning the SOLID principles. They give you a good set of guidelines to follow when refactoring shit code into not-bad code.
Yeah I was thinking it is a bit of a tricky thing to practise.
It's like a paired programming thing, they ring me on Skype and then I screen share with a guy, basically take it in turns doing the coding I think and have to correct each other and stuff.
Job sounds awesome and if I pass I have the job, so really hoping I can improve on my refactoring.
Hey guys, I'm working on a dynamic array in C++, I want it to double it's size on demand.
For some reason when I try to delete a pointed to array that I new'ed earlier it gives me a heap corruption error.
[code]
private:
StoredData * buffer_;
int size;
[/code]
StoredData is a typedef for an int
[code]
dynamicArray::dynamicArray(int initialSize)
{
buffer_ = new StoredData[initialSize];
size = initialSize;
for (int i = 0; i <= size; i++)
{
buffer_[i] = StoredData();
}
}
int dynamicArray::growDouble()
{
int newSize = 0;
if (size == 0)
{
newSize = 1;
}
else
{
newSize = size*2;
}
StoredData * tempBuffer_ = new StoredData[newSize];
for (int i = 0; i < sz_; i++)
{
tempBuffer_[i] = buffer_[i];
}
for (int i = 0; i < newSize; i++)
{
buffer_[i] = StoredData();
}
delete[] buffer_;
buffer_ = tempBuffer_;
size = newSize;
return 0;
}
[/code]
Whenever I try to delete[] buffer_ it gives me this error:
[t]http://puu.sh/euk9F.png[/t]
I'm not sure what am I doing wrong. Any help?
Sorry, you need to Log In to post a reply to this thread.