Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem 2, access the HKLM as Admin doesn't work Pin
jkirkerx22-May-16 7:28
professionaljkirkerx22-May-16 7:28 
AnswerRe: delete directory / folder recursive, by pass locked files [done] Pin
jkirkerx22-May-16 7:31
professionaljkirkerx22-May-16 7:31 
GeneralRe: delete directory / folder recursive, by pass locked files [done] Pin
Member 244330622-May-16 9:14
Member 244330622-May-16 9:14 
QuestionDotnetbar in C# Pin
Member 1051156220-May-16 1:18
Member 1051156220-May-16 1:18 
AnswerRe: Dotnetbar in C# Pin
Pete O'Hanlon20-May-16 1:42
mvePete O'Hanlon20-May-16 1:42 
JokeRe: Dotnetbar in C# Pin
Richard Deeming20-May-16 1:57
mveRichard Deeming20-May-16 1:57 
AnswerRe: Dotnetbar in C# Pin
Richard MacCutchan20-May-16 1:49
mveRichard MacCutchan20-May-16 1:49 
Questiontrouble with combobox and datagridviews Pin
Simon_Whale20-May-16 1:08
Simon_Whale20-May-16 1:08 
I'm trying to work out why here, but I am stuck and also have no GoogleFu luck on Friday

I have a datagridview which I attach a combo box to a specific cell with the following code.

C#
private void dg_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    DataGridView dg = sender as DataGridView;

    DataGridViewComboBoxColumn combo = dg.Columns[0] as DataGridViewComboBoxColumn;
    LogManager.Instance.Logger("Policy SI").Info("Edit Control Showing");
    if (dg.CurrentCellAddress.X == combo.DisplayIndex)
    {
        LogManager.Instance.Logger("Policy SI").Info("We have a combo");
        cb = e.Control as ComboBox;
        if (cb != null)
        {
            cb.SelectedIndexChanged -= new EventHandler(cb_SelectedIndexChanged);
            cb.DropDownStyle = ComboBoxStyle.DropDown;
            cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
        }
    }
}


the SelectedIndexChanged event takes a copy of the selected value's text.

C#
private void cb_SelectedIndexChanged(object sender, EventArgs e)
{
    originalDescription = cb.Text;
}


This works great, for all the grids that the edit control showing event is subscribed too, but while tracing another problem I have noticed that when I am getting the row out of the combo box's datasource which is a bindinglist and reading the information to pass back to the database. with the following simplified event below. Each property that I read then fires the selected index event of the combobox.

C#
private void dg_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            
            DataGridView dgB = sender as DataGridView;
            if (dgB.CurrentRow.IsNewRow == true) 
            {
                LogManager.Instance.Logger("Policy SI").Info("New Row ");
                return; 
            }

            if (e.ColumnIndex == 0)
            {
                LogManager.Instance.Logger("Policy SI").Info("Validating Col 1");
                string newDescription = string.Empty;
                newDescription = e.FormattedValue.ToString();

                quoteTemplate = valuablesBinding.FirstOrDefault(p => p.Description == originalDescription || p.Description == policySumInsured.Description);
                
                //Attempted here to deepclone the object from the valuables bindinglist
                //quoteTemplate = quoteTemplateNewDescription.DeepClone();  

                 //Here with these 3 lines it will then fire the selectedindexchanged 
                 //event that is on the combobox
                policySumInsured.ItemNo = (int)quoteTemplate.ItemNo;
                policySumInsured.Description = quoteTemplate.Description;
                policySumInsured.Section = quoteTemplate.Section;
            }
            else
            {
                if (e.ColumnIndex == 1)
                {
                    //Other validation routine here
                }
            }     
        }


Hopefully this all makes and sense and someone could possibley shed some light on why it keeps firing the cb_selectedIndexChanged event.

Thanks
Simon
Every day, thousands of innocent plants are killed by vegetarians.

Help end the violence EAT BACON

AnswerRe: trouble with combobox and datagridviews Pin
U. G. Leander20-May-16 1:37
professionalU. G. Leander20-May-16 1:37 
QuestionC# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Member 1253400819-May-16 23:35
Member 1253400819-May-16 23:35 
AnswerRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Pete O'Hanlon19-May-16 23:54
mvePete O'Hanlon19-May-16 23:54 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Member 1253400820-May-16 0:38
Member 1253400820-May-16 0:38 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Pete O'Hanlon20-May-16 1:00
mvePete O'Hanlon20-May-16 1:00 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Member 1253400820-May-16 4:25
Member 1253400820-May-16 4:25 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Member 1253400823-May-16 0:22
Member 1253400823-May-16 0:22 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Pete O'Hanlon23-May-16 0:28
mvePete O'Hanlon23-May-16 0:28 
QuestionUDP communication and CRC16 calculations Pin
MaWeRic19-May-16 22:58
MaWeRic19-May-16 22:58 
GeneralRe: UDP communication and CRC16 calculations Pin
harold aptroot19-May-16 23:55
harold aptroot19-May-16 23:55 
GeneralRe: UDP communication and CRC16 calculations Pin
MaWeRic20-May-16 0:12
MaWeRic20-May-16 0:12 
GeneralRe: UDP communication and CRC16 calculations Pin
harold aptroot20-May-16 1:05
harold aptroot20-May-16 1:05 
QuestionEnableRaisingEvents automatically sets to false Pin
IT - Researcher19-May-16 21:58
IT - Researcher19-May-16 21:58 
QuestionMigrating C# desktop application to Windows 10 Pin
UnlockSecrets4WeightLoss19-May-16 19:19
UnlockSecrets4WeightLoss19-May-16 19:19 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard MacCutchan19-May-16 21:25
mveRichard MacCutchan19-May-16 21:25 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard Deeming20-May-16 1:47
mveRichard Deeming20-May-16 1:47 
QuestionBuild navigation with routed URL in ASP.NET MVC Pin
Member 1204569219-May-16 19:16
Member 1204569219-May-16 19:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.