RdZoid
RdZoid
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
thank you for your help!
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
ok nice, weird workaround but a workaround nonetheless
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
holy shit that worked
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
like that^?
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
private void Refresh()
{
lbxCustomers.DataSource = null;
lbxCustomers.DataSource = customers;
lbxCustomers.DisplayMember = "FullName";
lbxCustomers.ValueMember = "Id";
lblStatus.Text = $"{lbxCustomers.Items.Count} Customers loaded";
lblStatus.ForeColor = Color.Blue;
dataSourceChange = true;
}
private void Refresh()
{
lbxCustomers.DataSource = null;
lbxCustomers.DataSource = customers;
lbxCustomers.DisplayMember = "FullName";
lbxCustomers.ValueMember = "Id";
lblStatus.Text = $"{lbxCustomers.Items.Count} Customers loaded";
lblStatus.ForeColor = Color.Blue;
dataSourceChange = true;
}
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
public partial class frmBanking : Form
{
List<Customer> customers;
MySettings settings;
private bool dataSourceChange;

public frmBanking()
{
InitializeComponent();

}

private void frmBanking_Load(object sender, EventArgs e)
{
this.dataSourceChange = true;
this.lbxCustomers.DataSource = new string[] { "foo", "bar" };
this.dataSourceChange = false;

try
{


settings = Program.Configuration.GetSection("MySettings").Get<MySettings>();

this.Text = settings.Text;


lblStatus.ForeColor = Color.Black;


//customers = CustomerManager.Populate();
customers = CustomerManager.ReadXML(settings.CustomerXMLFilename);


Refresh();



}
catch (Exception ex)
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = ex.Message;
}
}

private void Refresh()
{
lbxCustomers.DataSource = null;
lbxCustomers.DataSource = customers;
lbxCustomers.DisplayMember = "FullName";
lbxCustomers.ValueMember = "Id";
lblStatus.Text = $"{lbxCustomers.Items.Count} Customers loaded";
lblStatus.ForeColor = Color.Blue;
}



private void lbxCustomers_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.dataSourceChange)
{
this.lbxCustomers.SelectedIndex = -1;
return;
}

try
{
lblStatus.ForeColor = Color.Black;
lblStatus.Text = string.Empty;


if (lbxCustomers.SelectedIndex >= 0)
{
Customer customer = customers[lbxCustomers.SelectedIndex];

txtFirstName.Text = customer.FirstName;
txtLastName.Text = customer.LastName;
txtSSN.Text = customer.SSN;
txtId.Text = customer.Id.ToString();
dtBirthDate.Text = customer.Birthdate.ToString();


dgvDeposits.DataSource = null;
dgvWithdrawals.DataSource = null;


}

}
catch (Exception ex)
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = ex.Message;
}
}
public partial class frmBanking : Form
{
List<Customer> customers;
MySettings settings;
private bool dataSourceChange;

public frmBanking()
{
InitializeComponent();

}

private void frmBanking_Load(object sender, EventArgs e)
{
this.dataSourceChange = true;
this.lbxCustomers.DataSource = new string[] { "foo", "bar" };
this.dataSourceChange = false;

try
{


settings = Program.Configuration.GetSection("MySettings").Get<MySettings>();

this.Text = settings.Text;


lblStatus.ForeColor = Color.Black;


//customers = CustomerManager.Populate();
customers = CustomerManager.ReadXML(settings.CustomerXMLFilename);


Refresh();



}
catch (Exception ex)
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = ex.Message;
}
}

private void Refresh()
{
lbxCustomers.DataSource = null;
lbxCustomers.DataSource = customers;
lbxCustomers.DisplayMember = "FullName";
lbxCustomers.ValueMember = "Id";
lblStatus.Text = $"{lbxCustomers.Items.Count} Customers loaded";
lblStatus.ForeColor = Color.Blue;
}



private void lbxCustomers_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.dataSourceChange)
{
this.lbxCustomers.SelectedIndex = -1;
return;
}

try
{
lblStatus.ForeColor = Color.Black;
lblStatus.Text = string.Empty;


if (lbxCustomers.SelectedIndex >= 0)
{
Customer customer = customers[lbxCustomers.SelectedIndex];

txtFirstName.Text = customer.FirstName;
txtLastName.Text = customer.LastName;
txtSSN.Text = customer.SSN;
txtId.Text = customer.Id.ToString();
dtBirthDate.Text = customer.Birthdate.ToString();


dgvDeposits.DataSource = null;
dgvWithdrawals.DataSource = null;


}

}
catch (Exception ex)
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = ex.Message;
}
}
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
I might just have inserted it incorrectly, how do you add code here?
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
hmmm the bool thing didn't seem to work
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
it might be wacky but could I just "" the textboxes after the refresh() is called in form load?
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
That's weird, doesn't make it seem very indexchanged-ey, can you think of an easy way to make sure the txtboxes on the right side stay blank unless something's actually selected?
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
No description
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
No description
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
data source
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
it's being filled from an XML file
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
how can I have it not start selected/ at 0?
31 replies
CC#
Created by RdZoid on 5/3/2024 in #help
listbox SelectedIndexChanged on load?
I've verified this is the only space those get populated because if I comment that section out nothing loads there
31 replies