Hi there
My first forum post... internet being a luxury for me and all. Okay my program is a simple database management system connecting to an access database. however i am having one annoying problem, pertaining to a datagrid and a list box. they cannot be data bound as this gives problems,besides the code works but only if a message box is used for the list box code just before running its little bit, check for comment in list box code. Can you please explain to me why this works only for a message box appearal and if there is another way to get it to work as the message box is rather unwanted. If it is not used, simply nothing happens.
bool switcher = true;
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
dataGridView1.Refresh();
if (dataGridView1.CurrentRow != null && switcher)
{
int selectedrow = dataGridView1.CurrentRow.Index;
string currentpack = dataGridView1[2, selectedrow].Value.ToString();
if (currentpack == "1Kg")
{
radioButton1.Checked = true;
}
if (currentpack == "2Kg")
{
radioButton2.Checked = true;
}
comboBox1.SelectedValue = dataGridView1[1, selectedrow].Value;
}
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
int numrows = 0;
switcher = false;
MessageBox.Show(""); //This is what makes this work... Why?
if (comboBox1.SelectedValue != null)
{
string biscuitTpe = comboBox1.SelectedText;
string size;
if (radioButton1.Checked)
size = "1Kg";
else
size = "2Kg";
while (numrows < dataGridView1.RowCount)
{
if (dataGridView1[1, numrows].Value.ToString().Equals(biscuitTpe) && dataGridView1[2, numrows].Value.ToString().Equals(size))
{
dataGridView1.Rows[numrows].Selected = true;
}
numrows++;
}
}
}
private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
switcher = true;
}
Much Much appreciated