I have a property grid and a combo box, Based on the value of the combo box i change the propertygrid.SelectedItem and refresh the property grid.
The problem is that whenever i select a value to edit the whole screen starts flickering like it's repainting or redrawing. This only happens when i select a property on the property grid, it goes away when i go to another screen and comeback. I have not written any redraw functions on click events.
[edit1]I've added a code snippet of combo box selected item change
if (this.comboBoxHomerSelectSettings.SelectedItem.ToString() == "AppSettings")
{
this.comboBoxHomerSublist.Visible = false;
this.propertyGridEditSettings.SelectedObject = Settings.SingleInstance.SettingsValues.AppSettings;
}
else if (this.comboBoxHomerSelectSettings.SelectedItem.ToString() == "WaferSpecificSettings")
{
this.comboBoxHomerSublist.Visible = true;
this.comboBoxHomerSublist.Items.Clear();
for (int i = 0; i < Settings.SingleInstance.SettingsValues.WaferSpeicificSettingsList.WaferSpeicificInformationList.Count;i++ )
{
this.comboBoxHomerSublist.Items.Add(Settings.SingleInstance.SettingsValues.WaferSpeicificSettingsList.WaferSpeicificInformationList.ElementAt(i));
}
this.comboBoxHomerSublist.SelectedIndex = 0;
this.propertyGridEditSettings.SelectedObject = this.comboBoxHomerSublist.SelectedItem;
}
else if (this.comboBoxHomerSelectSettings.SelectedItem.ToString() == "BinColorMapping")
{
this.comboBoxHomerSublist.Visible = true;
this.comboBoxHomerSublist.Items.Clear();
for (int i = 0; i < Settings.SingleInstance.SettingsValues.BinColorInfoList.BinColorInformationList.Count; i++)
{
this.comboBoxHomerSublist.Items.Add(Settings.SingleInstance.SettingsValues.BinColorInfoList.BinColorInformationList.ElementAt(i));
}
this.comboBoxHomerSublist.SelectedIndex = 0;
this.propertyGridEditSettings.SelectedObject = this.comboBoxHomerSublist.SelectedItem;
}
else if (this.comboBoxHomerSelectSettings.SelectedItem.ToString() == "CommonSettings")
{
this.comboBoxHomerSublist.Visible = false;
this.propertyGridEditSettings.SelectedObject = Settings.SingleInstance.SettingsValues.CommonSettings;
}
else if (this.comboBoxHomerSelectSettings.SelectedItem.ToString() == "DOETypeMapping")
{
this.comboBoxHomerSublist.Visible = true;
this.comboBoxHomerSublist.Items.Clear();
for (int i = 0; i < Settings.SingleInstance.SettingsValues.DOETypeMapingInfoList.DOETypeMapingInformationList.Count; i++)
{
this.comboBoxHomerSublist.Items.Add(Settings.SingleInstance.SettingsValues.DOETypeMapingInfoList.DOETypeMapingInformationList.ElementAt(i));
}
this.comboBoxHomerSublist.SelectedIndex = 0;
this.propertyGridEditSettings.SelectedObject = this.comboBoxHomerSublist.SelectedItem;
}
this.propertyGridEditSettings.Refresh();
Related
While debugging the project the animation of the panel doesn't show... It only lags but doesn't show the transition.
if (sidePanel.Width == 260)
{
PanelAnimator.ShowSync(sidePanel);
sidePanel.Width = 0;
panelProduct.Height = 0;
panelOrdering.Height = 0;
panel4.AutoScroll = false;
}
else
{
PanelAnimator.ShowSync(sidePanel);
sidePanel.Width = 260;
panel4.AutoScroll = true;
}
This PanelAnimator.ShowSync(sidePanel); should be PanelAnimator.HideSync(sidePanel); since the sidepanel is already shown.
PS: sidepanel Visible property should be false before ShowSync(panel) V.V
Something like
if (sidePanel.Width == 260)
{
sidePanel.Width = 0;
panelProduct.Height = 0;
panelOrdering.Height = 0;
panel4.AutoScroll = false;
PanelAnimator.HideSync(sidePanel);
}
else
{
sidePanel.Width = 260;
panel4.AutoScroll = true;
PanelAnimator.ShowSync(sidePanel);
}
I have a form which changes Title depends on users selection. Then i want to create a properties for the control, either radiobutton or checkbox. They have same properties but i cant implement well.
private void DeleteEdit()
{
Control[] EmployeesControl; //I think this is the problem, but i cant figure it out.
if (Form_AddEmployee.Text.Contains("Edit"))
{
EmployeesControl = new RadioButton[numberOfEmployees];
}
else if (Form_AddEmployee.Text.Contains("Delete"))
{
EmployeesControl = new CheckBox[numberOfEmployees];
}
for (int i = 0; i < EmployeesControl.Count(); i++)
{
EmployeesControl[i] = new EmployeesControl();
InitializeControls(EmployeesControl[i]);
EmployeesControl[i].Visible = true;
panelEmployee.Controls.Add(EmployeesControl[i]);
EmployeesControl[i].Text = stringTemp;
EmployeesControl[i].Location = new Point(100, 100 * (i+1));
EmployeesControl[i].Font = MyFont;
EmployeesControl[i].CheckedChanged += EmployeesDeleteEditEmployees_CheckedChanged;
}
}
How can i make a variable if a certain control is a radiobutton or checkbox.
You can use GetType to check, after you will change EmployeesControl[i] to CheckBox or RadioButton.
private void DeleteEdit()
{
Control[] EmployeesControl; //I think this is the problem, but i cant figure it out.
if (Form_AddEmployee.Text.Contains("Edit"))
{
EmployeesControl = new RadioButton[numberOfEmployees];
for (int i = 0; i < EmployeesControl.Count(); i++)
{
EmployeesControl[i] = new RadioButton();
}
}
else if (Form_AddEmployee.Text.Contains("Delete"))
{
EmployeesControl = new CheckBox[numberOfEmployees];
for (int i = 0; i < EmployeesControl.Count(); i++)
{
EmployeesControl[i] = new CheckBox();
}
}
ButtonBase b;
CheckBox chk;
RadioButton rdo;
for (int i = 0; i < EmployeesControl.Count(); i++)
{
b = (ButtonBase)EmployeesControl[i];//You use b to set property
if (EmployeesControl[i].GetType() == typeof(RadioButton))
{
rdo = (RadioButton)EmployeesControl[i];
//Your code
//................
rdo.CheckedChanged += EmployeesDeleteEditEmployees_CheckedChanged;
}
else
{
chk = (RadioButton)EmployeesControl[i];
//Your code
//...............
chk.CheckedChanged += EmployeesDeleteEditEmployees_CheckedChanged;
}
//EmployeesControl[i] = new EmployeesControl();
//InitializeControls(EmployeesControl[i]);
//EmployeesControl[i].Visible = true;
//panelEmployee.Controls.Add(EmployeesControl[i]);
//EmployeesControl[i].Text = stringTemp;
//EmployeesControl[i].Location = new Point(100, 100 * (i + 1));
//EmployeesControl[i].Font = MyFont;
//EmployeesControl[i].CheckedChanged += EmployeesDeleteEditEmployees_CheckedChanged;
}
}
I hope it will help you.
You can use ButtonBase class to your perpouse.
Declare array of controls by ButtonBase, so common properties of CheckBox and RadioButton you can use without casting.
Properties of CheckBox or RadioButton you can access by
var a = EmployeesControl[i] as CheckBox;
if (a != null)
{
//this is checkbox
continue;
}
var b = EmployeesControl[i] as RadioButton;
if (b != null)
{
//this is RadioButton
}
I can't disable checkbox...
public void seat_reser_Load(object sender, EventArgs e)
{
string asd = "";
DataTable dt = ob.dataview("Select * from seat_res where bus_id='"+ bus_select.Id+"'and date='"+bus_select.date +"'");
foreach (DataRow d in dt.Rows)
{
asd += d[2].ToString(); // d[2] is seat column
asd+=",";
}
box[0] = CheckBox1;
box[1] = CheckBox2;
box[2] = checkBox3;
box[3] = checkBox4;
box[4] = checkBox5;
box[5] = checkBox6;
box[6] = checkBox7;
box[7] = checkBox8;
box[8] = checkBox9;
box[9] = checkBox10;
box[10] = checkBox11;
box[11] = checkBox12;
box[12] = checkBox13;
box[13] = checkBox14;
box[14] = checkBox15;
box[15] = checkBox16;
box[16] = checkBox17;
box[17] = checkBox18;
box[18] = checkBox19;
box[19] = checkBox20;
box[20] = checkBox21;
box[21] = checkBox22;
box[22] = checkBox23;
box[23] = checkBox24;
box[24] = checkBox25;
for (int h = 0; h < box.Length; h++)
{
box[h].Enabled = true;
}
string[] n = asd.Split(',');
for (int i = 0; i < n.Length; i++)
{
for (int j = 0; j < box.Length; j++)
{
if (n[i] == box[j].Text)
{
box[j].Enabled = false;
j++;
}
else if (!(box[j].Enabled == false))
{
box[j].Enabled = true;
}
}
}
}
Your code seems fine, did you want to set the checkbox's visibility or checked state to false, instead of disabling it? Did you want to make it invisible or simply unchecked?
In that case you might want to change your usage of Enabled to Visible or Checked, for example, like this:
box[h].Visible = false;
box[h].Checked = false;
What's the difference between Enabled, Checked and Visible?
Enabled - this will enable/disable the checkbox, you cannot check or uncheck the checkbox if it is disabled, however, the checkbox will still be visible on screen
Checked - this will check/uncheck the checkbox, it's identical to user actually clicking the checkbox
Visible - this will make the checkbox visible/invisible, so that user cannot see the control, nor can he click on it or interact with it in any way
I have the WinForm, there I have a lot of controls, and on certain moments I need to change the properties for some of them.. so, I create the Control array and determines what should be changed
controls = new Control[] {loadFromFile_btn, logout_btn, postBtn, waitFrom_tb, waitTo_tb, messageTB, recurs_check};
ChangeStatus.activStatus(controls);
Then in my class ChangeStatus make changes to all of these elements are in an array
public static void activStatus(Control[] controlObj)
{
for (int i = 0; i < controlObj.Count() - 1; i++)
{
controlObj[i].BeginInvoke((Action)delegate
{
if (controlObj[i] is TextBox || controlObj[i] is CheckBox || controlObj[i] is Panel)
controlObj[i].Enabled = true;
else
{
controlObj[i].BackColor = Color.DarkGray;
controlObj[i].Enabled = true;
}
});
}
}
But I have a problem... the change applies only to the last element in the array. Help me please..
That's because of the closure.Try storing i in a local variable and use it in your anonymous method
for (int i = 0; i < controlObj.Count() - 1; i++)
{
int j = i;
controlObj[i].BeginInvoke((Action)delegate
{
if (controlObj[j] is TextBox || controlObj[j] is CheckBox || controlObj[j] is Panel)
controlObj[j].Enabled = true;
else
{
controlObj[j].BackColor = Color.DarkGray;
controlObj[j].Enabled = true;
}
});
}
What should I add to my code to only show the results of my search?
Right now when I search the searchresult becomes selected (highlighted) and the others remain the same.
Been trying to hide the other rows but without any success (and only show the searchresult, alone). Any suggestions?
Im using a datagridview.
My code:
private void button3_Click_1(object sender, EventArgs e)
{
string search = textBox1.Text;
for (int i = 0; i < dgTest.Rows.Count; i++)
{
if (dgTest.Rows[i].Cells[0].Value.ToString() == search)
{
dgTest.Rows[i].Selected = true;
break;
}
else
{
dgTest.Rows[i].Selected = false;
}
}
}
If your DataGridView is not bound to a data source, then setting the row's Visible property to false will hide it:
for (int i = 0; i < dgTest.Rows.Count; i++)
{
var row = dgTest.Rows[i];
if (row.Cells[0].Value.ToString() == search)
{
row.Selected = true;
row.Visible = true;
}
else
{
row.Selected = false;
row.Visible = false;
}
}
(I removed the 'break' command, as even after you have found the matching row, you would want to continue and hide the other rows.)
If you're using DataBinding, though, it's not so easy, as shown in this page.
you can try this:
for (int i = 0; i < dgTest.Rows.Count; i++)
{
if (dgTest.Rows[i].Cells[0].Value.ToString() == "search")
{
dgTest.Rows[i].Selected = true;
dgTest.Rows[i].Visible = true;
}
else
{
dgTest.Rows[i].Visible = false;
dgTest.Rows[i].Selected = false;
}
}