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);
}
Related
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();
I am in need of some assistance or advice/experience of someone else.
Here is what I'm struggling with:
In my project an objectlistview olvDifference is used to visualize items (Type Conflict) of a list. So far I was able to add the Columns needed and format them properly. But the format provided with
private void ConflictFormatRow(object sender,
BrightIdeasSoftware.FormatRowEventArgs e)
{
Conflict conflict = (Conflict)e.Model;
if (conflict == null) return;
if (conflict.resolution == ConflictResolution.None) e.Item.BackColor = conflictColor;
else if (conflict.resolution == ConflictResolution.UseMine) e.Item.BackColor = mineColor;
else if (conflict.resolution == ConflictResolution.UseTheirs) e.Item.BackColor = theirsColor;
else e.Item.BackColor = System.Drawing.Color.White;
if(e.Model == olvConflictList.SelectedObject)
{
BrightIdeasSoftware.RowBorderDecoration a = new BrightIdeasSoftware.RowBorderDecoration();
a.BorderPen.Color = Color.Black;
a.BorderPen.Width = 3;
a.CornerRounding = 0;
a.FillBrush = Brushes.Transparent;
e.Item.Decoration = a;
}
else
{
BrightIdeasSoftware.RowBorderDecoration b = new BrightIdeasSoftware.RowBorderDecoration();
b.BorderPen.Color = Color.Transparent;
b.BorderPen.Width = 0;
b.CornerRounding = 0;
b.FillBrush = Brushes.Transparent;
e.Item.Decoration = b;
}
}
In the constructor of the form (WFA), the AspectGetter is assigned and the objects to display are set.
Designer-Generated code equals the block below:
//
// olvConflictList
//
this.olvConflictList.AllColumns.Add(this.olvcConflictList);
this.olvConflictList.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.olvConflictList.CellEditUseWholeCell = false;
this.olvConflictList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.olvcConflictList});
this.olvConflictList.Cursor = System.Windows.Forms.Cursors.Default;
this.olvConflictList.FullRowSelect = true;
this.olvConflictList.Location = new System.Drawing.Point(780, 90);
this.olvConflictList.Name = "olvConflictList";
this.olvConflictList.Size = new System.Drawing.Size(286, 489);
this.olvConflictList.TabIndex = 18;
this.olvConflictList.UseCellFormatEvents = true;
this.olvConflictList.UseCompatibleStateImageBehavior = false;
this.olvConflictList.View = System.Windows.Forms.View.Details;
this.olvConflictList.FormatRow += new System.EventHandler<BrightIdeasSoftware.FormatRowEventArgs>(this.ConflictFormatRow);
this.olvConflictList.SelectedIndexChanged += new System.EventHandler(this.olvDifferenceGroups_SelectedIndexChanged);
//
// olvcConflictList
//
this.olvcConflictList.AspectName = "";
this.olvcConflictList.AutoCompleteEditor = false;
this.olvcConflictList.AutoCompleteEditorMode = System.Windows.Forms.AutoCompleteMode.None;
this.olvcConflictList.FillsFreeSpace = true;
this.olvcConflictList.Groupable = false;
this.olvcConflictList.HeaderCheckBoxUpdatesRowCheckBoxes = false;
this.olvcConflictList.Hideable = false;
this.olvcConflictList.IsEditable = false;
this.olvcConflictList.MinimumWidth = 50;
this.olvcConflictList.Searchable = false;
this.olvcConflictList.Sortable = false;
this.olvcConflictList.Text = "Conflicts";
this.olvcConflictList.UseFiltering = false;
this.olvcConflictList.Width = 283;
The only item in the olv has no BackGroundColor (White, default):
After starting the process, it is shown as one can see in the pic above, but I'd expect it to be initialized as in the pic below (after I hovered over it with my mouse the first time).
The only item in the olv has BackGroundColor conflictColor as assigned in the ConflictFormatRow:
Where do I need to improve my code? Any advices?
Well, I could figure it out myself.
I took a look at the source of OLV and what i found out so far:
In my case, the first row, here "Conflicts", was set to "Groupable=False", but the OLV itself was set to "ShowGroups=True".
FormatRow is fired in PostProcessOneRow, which is called according to source (Version: 2.9.1.0) in following logic:
protected virtual void PostProcessRows() {
// If this method is called during a BeginUpdate/EndUpdate pair, changes to the
// Items collection are cached. Getting the Count flushes that cache.
#pragma warning disable 168
// ReSharper disable once UnusedVariable
int count = this.Items.Count;
#pragma warning restore 168
int i = 0;
if (this.ShowGroups) {
foreach (ListViewGroup group in this.Groups) {
foreach (OLVListItem olvi in group.Items) {
this.PostProcessOneRow(olvi.Index, i, olvi);
i++;
}
}
} else {
foreach (OLVListItem olvi in this.Items) {
this.PostProcessOneRow(olvi.Index, i, olvi);
i++;
}
}
}
Since grouping failed, due to no groupable rows being present in OLV, the PostProcessOneRow in the if-body was not hit even once (foreach operated in "this.Groups" whichs count was 0).
Set "ShowGroups=False", works like a charm now.
I've been searching this page and other pages in this matter. I know it's not possible to get the data inside the while loop with direct assigning of variables, so I've tried to put it to label before and it works but only to the first value of the finalcred and finaldeb. It will not reset to fetch another value, so my real question is; Is there any other way to get the value inside the while loop and use it outside?
I have tried to declare it outside while and assign default value and the result will always be the default. It will not change.
r = t.NewRow();
//somecode..all good here
while (counterdate <= monthval)
{
//allgood in this part
totalcred = 0;
totaldeb = 0;
balance = 0;
crednum = 0;
debnum = 0;
if (readgetcode1.HasRows)
{
while (readgetcode1.Read())
{
readgetcred.Read();
readgetdeb.Read();
if (readgetdeb.HasRows)
{
debnum = Convert.ToDecimal(readgetdeb.GetValue(0));
}
else
{
debnum = 0;
}
if (readgetcred.HasRows)
{
crednum = Convert.ToDecimal(readgetcred.GetValue(0));
}
else
{
crednum = 0;
}
totalcred += crednum;
totaldeb += debnum;
if (strType == "Debit")
{
balance = totaldeb - totalcred;
}
else
{
balance = totalcred - totaldeb;
}
allbal += balance;
}
}
else
{
allbal = 0;
}
if (readprevCred.HasRows)
{
prevBalNum = Convert.ToDecimal(readprevBal.GetValue(0));
}
else
{
prevBalNum = 0;
}
if (strType == "Debit")
{
finaldeb = prevBalNum + allbal;
finalcred = 0;
}
else
{
finalcred = prevBalNum + allbal;
finaldeb = 0;
}
counterdate++;
}//while counterdate looping
r["accntCode"] = codevalue;
r["accntName"] = accntnameval;
r["DebitAmount"] = finaldeb;//this is the problem
r["CreditAmount"] = finalcred;;//this is the problem
t.Rows.Add(r);
//while readcodecheck in counter for code
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
How do I do this in a loop.
protected void ddlTool_SelectedIndexChanged(object sender, EventArgs e)
{
lblTool1.Visible = false;
txtTool1.Visible = false;
lblTool2.Visible = false;
txtTool2.Visible = false;
lblTool3.Visible = false;
txtTool3.Visible = false;
lblTool4.Visible = false;
txtTool4.Visible = false;
lblTool5.Visible = false;
if (ddlTool.SelectedValue == "1")
{
lblTool1.Visible = true;
txtTool1.Visible = true;
}
if (ddlTool.SelectedValue == "2")
{
lblTool1.Visible = true;
txtTool1.Visible = true;
lblTool2.Visible = true;
txtTool2.Visible = true;
}
if (ddlTool.SelectedValue == "3")
{
lblTool1.Visible = true;
txtTool1.Visible = true;
lblTool2.Visible = true;
txtTool2.Visible = true;
lblTool3.Visible = true;
txtTool3.Visible = true;
}
if (ddlTool.SelectedValue == "4")
{
lblTool1.Visible = true;
txtTool1.Visible = true;
lblTool2.Visible = true;
txtTool2.Visible = true;
lblTool3.Visible = true;
txtTool3.Visible = true;
lblTool4.Visible = true;
txtTool4.Visible = true;
}
Instead of having a separate variable for each textbox and label, have a collection of them - whether that's a List<T> or an array or whatever.
Then you can do:
// Potentially use int.TryParse here instead
int visibleLabels = int.Parse(ddlTool.SelectedValue);
for (int i = 0; i < labels.Count; i++)
{
labels[i].Visible = (i < visibleLabels);
textBoxes[i].Visible = (i < visibleLabels);
}
(Alternatively use two loops, one to set some Visible properties to true, and one to set some to false.)
You can access a control by its name using
container.Controls["nameofcontrol"]
So technically, you could use this to lookup your control
(Untested code)
for(int index = 1; index <= Convert.ToInt32(ddlTool.SelectedValue); index++)
{
this.Controls["lblTool" + index.ToString()].Visible = true;
this.Controls["txtTool" + index.ToString()].Visible = true;
}
Use a UserControl for each set of connected controls and then enable/disable the UserControl instead of all the component controls. This is classic, basic modularization of your user interface.
Note that this will still require a little "redundant" code because you're working with an unusual UI paradigm by enabling up-to the ddlTool's selected value of your control. E.g., create your user control that contains a single Label and TextBox. Call it LabeledTextBox or something similar. Then you'd create a collection of your labeled text boxes and enable them up to int.Parse(ddlTool.SelectedValue) - 1.
foreach (Control ctrl in this.Controls)
{
int index = (int)ctrl.Name.Substring(ctrl.Name.Length - 1);
int maxIndex = (int)ddlTool.SelectedValue;
ctrl.Visible = (index <= maxIndex);
}
Here is an example with no error checking, but should match your code functionality.
protected void ddlTool_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedValue = int.Parse(ddlTool.SelectedValue.ToString());
for (int i = 1; i <= 4; ++i)
{
bool state = i <= selectedValue;
this.Controls["lblTool" + i.ToString()].Visible = state;
this.Controls["txtTool" + i.ToString()].Visible = state;
}
}