I have a listbox that retrieves a bunch of values. I'm able to selectAll, Select None and Select Individual items. I'm not able to search the ListBox and select based on String value.
I have tried creating a for and if loop, but it will only select a single item (first item) in my ListBox.
private void btnSelectCAD_Click(object sender, EventArgs e) {
// Find CAD Line Patterns that Begin with IMPORT:
string mySearchString = "IMPORT";
// Search Listbox starting from index -1:
int index = lstLinePatterns.FindString(mySearchString, -1);
I'm working on creating a windows form with a listbox, textbox, and 2 buttons (add,remove). I need a way of removing every string matching the contents of the textbox from the listbox. Here's what I have:
for (int i=0;i<listBox1.Items.Count;i++) { //... listBox1.RemoveAt(i--) }
Seems to work, but I need a way to show a error message once the user clicks 'remove' and no items in the listbox match.
Is there a way to set the height of a listBox to show all of the items without having to kick in the vert scrollbars? I've searched on this question but can't find how to do this.
I want to kind of auto-size my listBox height to accommodate my items (within reason and perhaps set a max height which would kick in the vert scroll bars.
I am writing a program in Visual C++ 10 with 2 forms.
In the first form I have a textbox and a button. The button opens the second form.
In the second form, I have a button that changes the text in the textbox in form1 to an item from a listbox in form2.
Here is my problem. When I do the code for the button in form2 to change the textbox in form1 I get the errors:
error C2065: 'textBox1' : undeclared identifier error C2227: left of '->Text' must point to class/struct/union/generic type
I thought maybe I should just include the "Form1.h" file but I can't do that because I already included "Form2.h" in form1 in order to be able to open the second form. If I try to include form1 in form2, it says that the code to open form2 is an error now.
My question is, how can I access identifiers such as "textbox1" from other forms and other files when I already used the first form to open the second form? I also want to know how to do this for all identifiers between all files.
how to print the selecteditem from a listbox into a textbox because that doesn't work by just setting them equal either.
Here is my code:
#pragma once #include "Form2.h" namespace Test1 { using namespace System;
I have created a Server that can handle multiple users with the select function. The server seems to be operating just fine on every new request of a client even on the case of termination connection. The problem appears on the client side. I am applying forking process to be able to hear and write at the same time while the user is typing a message to the rest of the clients. By doing so I discovered that when the client is initialized it send a blank message to the server. The server then send this blank message to all the clients. I have discovered a "trick" not to display the message on the client side but I really would like to know if there is an alternative solution instead of my solution. I mean why it dose not wait for the client to first start typing a message before to send it.
The communication that will apply on each new connection is:
Client Server Connect() −− > < −− Hello version NICK nick −− > < −− OK/ERROR text MSG text −− > < −− MSG nick text/ERROR text
Sample of the Server.c code:
#include <stdio.h> /* stderr, stdout */ #include <errno.h> /* errno.h - system error numbers */ #include <stdlib.h> /* memory allocation, process control etc. */
I am working on a windows application that is for make a time schedule for all staff. i am using two gridview one for all staff names from employee table , and second is for time schedule, time schedule DGV is like 6to7 , 7 to8...12to1,... 5to6 columns . when user will select like 7to8 , 8to9,9to10, columns with holding ctrl key , thn i have to assign some work beteen these time for 3 hours. So i have to get multiple columns from Gridview.
I'm writing a Hotel magmt app. I'm having difficulty on how to implement a hotel attendant selecting/secure multiple rooms(with nos) for a Customer using combobox or listbox or something. How my interface will look like and techniques.
Im working on a script compiler and i need to handle different types of data. Actually different categories of items.
Let's say i have two categories: cat's and bird's. They are different and stored in different lists. And let's say there is a simple command: GIVE_FOOD_TO(animal_type, food_type) Animal type here can be either from birds category or cat's category.
And also let's say user gives command: GIVE_FOOD_TO(cat1, fish) and also for example: GIVE_FOOD_TO(bird1, birdfood)
Variable names could be anything, but im storing each variable name in std::map so later i can figure out with what animal current command is used.
When im parsing the script then i must know if user supplied either cat or bird. If i just would have cat's or bird's category then i would have only 2 lists and not a big problem to loop through either cats list or birds list and find out in what list the "cat1" is or in what particular list the "bird1" is. It would be in one or another.
But i have a lot of categories and looping through all of these lists (or std::maps) is slow and doesn't seem like a good. Just to find out in what list it's stored. I can't rely on variable names, they could be anything.
Big picture atm:
1) I have one BIG box which stores all of the categories
2) When i need to find out to which category the variable (animal_type) point's to i must get it quickly, dunno, std::map in std::map or something?
What i need basically is: I have different lists (each one is just a category for either birds or cats in this example) And when i have variable name, i must find out quickly in what particular category this item is stored. So i can work with it.
Okay so i have everything right accept transfering the selectedindex from listbox in form1 to listbox in form2. I am using the below string item to hold the selected line of the list box, with the intent of recalling and then adding it into the form2 listbox. I get a not implemented error and i can't figure out why. I know the information is moving with the variable item, it just doesn't get printed out to the new listbox.
I am struggling with a project right now and I was wondering if there was a quick way to find multiple modes in a map. So far I have a function that returns a vector of one or many modes depending on the map. I can't seem to wrap my head around how to test it->second against other seconds to find the one that occurs most often.
How to sum groups in C++? I have a class with 2 attributes (Group and Price). I need to find the group with the highest amount. I can find the max when it comes to finding a set of individual numbers but not when a group is required. For Ex:
Group A64 Group A48 Group A18 Group B49 Group B36 Group C64 Group C75 Group C87 Group C72
I just started on a project on c++ and I was wondering if it is possible to add a select option (where the c++ program requires the user to select an option) . I couldn't find this anywhere.
[ImportingConstructor] public MainForm([ImportMany] IEnumerable<AudioPlugin> content) {
[Code].....
However, when I add to the listbox as shown above in my main form code the results all show on the same line. My understanding was that they should all be treated as separate because of foreach loop but apparently that is incorrect. I have seen mixed things online some showing that its required to use AddRange instead of Add, however, after literally hours of trying to make this work I am still coming up with nothing. I can't seem to get any code to work using the AddRange or am I finding any way to output each results on a separate line.
I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.
I tried using:
if (lstLinePatterns == null) return; for (int i = 0; i < lstLinePatterns.Items.Count; i++) lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;
But .Selected is giving me an object error.
Is there an easy way to just inverse current selection?
Current Code:
private void btnSelectNonRvt_Click(object sender, EventArgs e) { // Unselects any Items to Prevent Infinite Loop lstLinePatterns.SelectedIndex = -1;
I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.
Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:
I am working on a Windows From application on Visual Studio 2010 where i need to use two checkedlistbox that interacts one with the other one. Let say that the first checkedlistbox is for world regions (i.e.):
Asia Africa Europe South America
And let say that the second checkedlistbox is for Countries (i.e.):
Spain Italy Romania Monaco
(all of this belongs to Europe region)
What we need to do is that when the user check on any world region it automatically checks all the countries on that region in the second checkbox, and vice versa if the users check any country on the second checkedlistbox it automatically seconds the region on the first one.
I know that is possible in Java and we know how to do it, but i don't know if C# supports this and how to do it. I was looking on the class information in the microsoft website: [URL] .... but not a concrete example on how to do it.
I have a lstYourHand that has two cards in it, I loop through the listbox to get the values of both cards. I take the string value of the listbox item (strCardVal) and use a switch to give it an integer value (intCardVal). For some reason, when I run the code, the message Box at the end gives me the value 0 as a result, it does not register me giving it a value in the switch statement. My code is below:
I was working with a richTextBox on setting its font, color and size. I found examples and got that to work. It seems like a kludge to me just to get the size set.
So, now I need to do the same for a listBox. I got the font and color set but cannot get the font size set.
The error I am getting is on line 6 below: listBoxTopLevelChecklist.Font.Size = fontDialog.Font.Size;
VS 2013 Express tells me this property (font.size) is read-only. That was the same error I got on the richTextBox until I found way using the .SelectionFont structure, but the listBox doesn't support that. So, I'm stuck.
Line 8 on is working finr for the richEditBox.
DialogResult result = fontDialog.ShowDialog(); if (result == DialogResult.OK) { listBoxTopLevelChecklist.Font = fontDialog.Font; listBoxTopLevelChecklist.ForeColor = fontDialog.Color; listBoxTopLevelChecklist.Font.Size = fontDialog.Font.Size;
I've changed the listbox foreground color to default application background color so I get: [URL] which is fine but when I select any element I get white background/foreground(or whatever it is): [URL]
How can I change this so I will have the same default color in the second case?
I'm making a simple airline reservation. I have two list boxes one has the section (A, B, C, etc) and the other rows (1, 2, 3, etc). I used two different arrays to put the values into the list box via form unload. The problem I can't seem to figure out is how can I update these seats and inform the user if a seat is taken or not. Lets say a customer takes A-1 (only seat taken). If I try to add someone else there it will inform me that seat is taken and to select another one. If all the seats are taken it'll tell me to put customer into the waiting list.
Also one more thing is that each row has 3 seats, so A-1, A-2, A-3 for example. If say A-1, A-2 are taken when I push a button show remain seats it should show A-3 only. I have a lot od struggle using arrays.