C# :: Two Checked Listbox - One Interacts With Other
Aug 31, 2014
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.
View 5 Replies
ADVERTISEMENT
Jul 4, 2014
what i want is to be able to change checked items within the listbox if not is there an alternative, is it possible?
View 4 Replies
View Related
Sep 11, 2014
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.
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
Form2 form2 = new Form2();
form2.Show(item.ToString());
[Code]....
View 13 Replies
View Related
Jun 2, 2014
My main form I have the following code
[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.
View 7 Replies
View Related
Jun 25, 2013
I have a problem with SendMessage. Anything I send doesn't show up but instead empty lines appear. What is wrong with my code?
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");
wchar_t listBoxStr[15];
[code].....
View 7 Replies
View Related
Apr 18, 2014
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;
[Code]....
View 3 Replies
View Related
Jun 5, 2014
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:
MyForm
public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}
View 9 Replies
View Related
Apr 3, 2015
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:
Int32 intCardVal = 0;
String strCardVal;
Int32 intLoopCounter1;
for (intLoopCounter1 = 0; intLoopCounter1 == 1; intLoopCounter1++) {
strCardVal = lstYourHand.SelectedItem.ToString();
[Code] .....
View 3 Replies
View Related
Mar 5, 2014
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.
View 6 Replies
View Related
Jun 24, 2014
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;
[Code] .....
View 2 Replies
View Related
Dec 22, 2014
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?
It is a windows store app
Xaml code(listbox is at the end):
<Page
x:Name="pageRoot"
x:Class="ExchangeRate2.MainPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
[Code]....
View 1 Replies
View Related
Sep 18, 2014
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.
View 3 Replies
View Related
Aug 2, 2014
I have a C# WPF program that takes a SQL query and populates a column from an Oracle database into a listbox on the form. I would like to be able to compare all items populated in the listbox, and run a SQL query for each item, populating those values into a different listbox.
So far, I have this code:
string sql2 = "select unique apps.fnd_application_all_view.application_name, fnd_responsibility_vl.responsibility_name, fnd_form_functions_tl.user_function_name, fnd_form_functions.function_name, fnd_form_functions_tl.description, fnd_form_functions.type FROM fnd_compiled_menu_functions, fnd_form_functions, fnd_form_functions_tl, fnd_responsibility, fnd responsibility_vl, apps.fnd_application_all_view WHERE
[code]....
I would like to be able to basically take the "Responsibility_Name" value from the first listbox (lstResponsibilities), which is already populated, and use those values to in the "sql2" query to find the "Function_Name" and populate "Function_Name" in the second listbox (lstFunctions).
View 5 Replies
View Related
Mar 3, 2014
i've a function to add many buttons to TabbedPanel like is visible here
public void AddBeverageDrinkstoTabbedPanel(TabPage tp1, ListBox lst1) {
food getbeverage = new food();
string[] bev_product = getbeverage.name1;
FlowLayoutPanel flp1 = new FlowLayoutPanel();
flp1.Dock = DockStyle.Fill;
foreach (string value in bev_product)
[code].....
What happens? When i click in any button, want add an specific text to listbox and to do this i builded an method called beverageclick(), with these code:
public void beverageclick(object sender, EventArgs e) {
Button b = (Button)sender;//button sender
string value = (string)b.Tag;// value = b.tag (tag of sended button tag = value (value of AddBeverageDrinkstoTabbedPanel) method)
[Code] ....
What is wrong? how can i add an specific value when an button was clicked.
View 1 Replies
View Related
Feb 15, 2015
Startthread get called to launch to update list box.
a)is it the only way to pass string to the PostMessage?. my concern is that allocate using new in each iteration each time slows it down a bit.
b)does OnAddToListBox look memory leak free?.
c)What is the best way handle m_pThread at the end?. Any way to improve it?.
Code:
UINT CMyDlg::Dump(LPVOID lparam) {
HWND *pHndl = static_cast<HWND *>(lparam);
char buffer[200];
for (int i = 0; i < 100; i++) {
sprintf_s(buf,"user %d, data %s",i, "Connected");
[Code] ....
View 8 Replies
View Related
Apr 7, 2014
program im creating that is a Mediastore. I have 3 forms one start form where you choose which form you wanna go to Lager or Kassa are the two choices. in these forms i have 1 listbox each that share the same Data. In my Listboxes i have objects of a class called produkts that consist of 3 variables Name,SerialNumber and Price. When i have added these objects to my listbox and they are showing i wanna be able to use my "go back" button to go back to my orginal form where i choose which form i wanna go to and then go to eather my Lager form or my Kassa form and the items are supposed to still there however that is not happening for some reason.
public Lager()
{
InitializeComponent();
}
[Code].....
View 2 Replies
View Related
Jan 17, 2013
how is it done?
ex. mp3player keeps songs loaded
View 1 Replies
View Related
Feb 16, 2015
This is my second hw doing C# and I'm trying to sort my objects I have in the ListBoxes,when I remove them from the ListBox on the right then get added to the original ListBox(because when i click add it removes the item and sends them to the ListBox on the right),but when i add them the go at the end of the list and they order should matter,how can i sort the list after the were added back?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//Patricio Vargas
public partial class _default : System.Web.UI.Page {
[Code] .....
View 3 Replies
View Related
Jul 21, 2014
I've a winapi listbox with a bunch of entries, I'd like that when the user click on an entry, the entry number will be saved on an integer variable.
View 3 Replies
View Related
Jun 28, 2014
I started learning programming a few days ago and i'm having trouble with reading each line from a listbox this is the code i'm having trouble with
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string[] getFlies
{
get;
set;
[Code]....
What am I doing wrong?
View 5 Replies
View Related
Apr 18, 2014
I need to take a single column and all the rows in the column from a datagridview to a listbox using a for loop. My code is giving me no errors just not showing any data in the listbox.
private void frmProject6_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'enrollmentsDataSet.Enrollments' table. You can move, or remove it, as needed.
this.enrollmentsTableAdapter.Fill(this.enrollmentsDataSet.Enrollments);
[Code] .....
View 1 Replies
View Related
Jul 24, 2014
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.
View 9 Replies
View Related
Apr 19, 2014
I tried to save some data from my listbox to the text file, but didn't work... I think I tried many combination for code but still didn't work. what to do?
FileStream fs = new FileStream("tx.txt", FileMode.Create);
StreamWriter sr = new StreamWriter(fs);
sr.Write(listBox1.Text); //there is that problem, but I'm not sure how to write for success
sr.Close();
View 4 Replies
View Related
Mar 31, 2013
What codes in c# will output items in a list box?
View 2 Replies
View Related
Jan 17, 2013
The process cannot access the file because it is being used by another process.
How can i edit CStdioFile to let me open the file while the program is running.
View 2 Replies
View Related
Sep 27, 2014
i found somewhere online this code that populate my listbox with file names. Now is it anyhow possible to filter those names before it gets populated by regex ?
Code:
private void PopulateListBox(ListBox lsb, string Folder, string FileType)
{
DirectoryInfo dinfo = new DirectoryInfo(Folder);
FileInfo[] Files = dinfo.GetFiles(FileType);
foreach (FileInfo file in Files)
{
lsb.Items.Add(file.Name);
}
}
Call on form load:
PopulateListBox(listBox1, Application.StartupPath, "*.exe");
Now is there way to add regex for filename?
View 5 Replies
View Related