Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
N

Nigel Mackay

@Nigel Mackay
About
Posts
73
Topics
32
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Bound DataGridView with unbound text box column
    N Nigel Mackay

    Yes, that would work. In fact it rings a bell from many years ago, along with CellValueNeeded and CellValuePushed. Because I only have 2 bound and 1 unbound column and the grid is Read Only I created the grid manually. That way I can populate the grid while it is being built.

    C# css question

  • Bound DataGridView with unbound text box column
    N Nigel Mackay

    The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table. I have my grid displaying nicely, with the empty text box column. I have the values to insert into the grid. But when do I do it? With which event handler? I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called. EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.

    C# css question

  • Problem with Process.HasExited
    N Nigel Mackay

    I must have misunderstood the examples in the answers to other similar questions!! Working now.

    C# debugging help

  • Problem with Process.HasExited
    N Nigel Mackay

    Using a windows app to batch run a DOS program. Need to wait until the DOS app has finished before going on with the next file. Using:

    Process.Start(thecommand, thearguments);
    System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
    while (!p.HasExited)
    {
    aaa=5;
    }

    but it seems to be waiting for my windows app to end, not the DOS app. I can see my DOS app running in a DOS window, and it closes when finished (it takes about a minute to run), but my app sits there in the while loop. I put a breakpoint at aaa = 5; and the app definitely sits in that loop.

    C# debugging help

  • Cancel CellValidating error in DataGridView, so can close form while invalid entry still present
    N Nigel Mackay

    As far as I can remember I didn't solve the problem. User must press Esc to cancel the edit before doing ANYTHING else. You notice no-one offered a solution.

    C# help

  • Need help with code
    N Nigel Mackay

    Partial solution! There will be lots of entries where a specific PartID was ordered and delivered. But now they need ordering again. As written, only allows parts that have never been ordered. So needs one more clause only zapping PartID's that have oo.Ordered == oo.Received So I have changed it to

    neededParts = from np in MainMenu.db.Parts
    where np.Stock < np.OrderLevel
    &&
    (
    from oo in MainMenu.db.Orders
    where (oo.PartID == np.PartID) && (oo.Ordered==oo.Received)
    select oo
    ).Count() == 0
    orderby np.StoreNumber
    select np;

    and it works just the way I want. Thanks for the help. It gives the solution to other posiible scenarios as well.

    LINQ database question help

  • Need help with code
    N Nigel Mackay

    Table Parts has PartID as identity Table Orders has a field PartID as a foreign key As the stock of a part drops below OrderLevel it gets ordered and delivered. So many orders for this part. Come end of the month I need a list of Parts where Stock < OrderLevel, but no outstanding Order exists. This was easy using SQL and Datasets - just delete the row in the dataset if there is an Order for that PartID where Received < Ordered. But if I use

    neededParts = from np in MainMenu.db.Parts
    where np.Stock < np.OrderLevel
    orderby np.StoreNumber
    select np;

    and then identify PartID's that need to be removed, how do I do the removal? I could add a field to Parts, AreNeeded, and set that flag and then put that in the where statement. Doesn't seem very elegant.

    LINQ database question help

  • Problem binding arraylist to combobox
    N Nigel Mackay

    private struct modelStruct
    {
    public string theModel;
    public int theModelID;
    }
    private modelStruct thisModelStruct;
    private ArrayList availableModels = new ArrayList();

    I add some items to the arraylist. Then I want

    cboModel.DataSource = availableModels;
    cboModel.DisplayMember = "ModelID";
    cboModel.ValueMember = "theModelID";

    But I need to do some casting or content exctraction, but where and how? For DisplayMember the combobox shows "ToolHistory.History+modelStruct". I have tried cboModel.DisplayMember = thisModelStruct.theModel; but it makes no difference.

    Windows Forms wpf wcf help question

  • Using query with where clause as datasource for combobox
    N Nigel Mackay

    Of course :)

    LINQ database question

  • Using query with where clause as datasource for combobox
    N Nigel Mackay

    I can easily bind a simple query to a combobox. But if I have a where clause in the query it doesn't work: Complex DataBinding accepts as a data source either an IList or an IListSource. Is there a way to overcome this?

    LINQ database question

  • foreach referencing different rows
    N Nigel Mackay

    And Zip would work for any supplied formula. Very useful addition.

    LINQ question csharp database linq

  • Stuck trying to learn to do SubmitChanges
    N Nigel Mackay

    Every now and again one forgets :)

    C# help database question

  • Stuck trying to learn to do SubmitChanges
    N Nigel Mackay

    I actually misinterpretted your answer, seeing only the bit about not using password as the primary key, and not adding another column for userID, because I don't need it, as I ony have one password. I later remembered that inserts, deletes and changes only work if there is a primary key. So I have a column for primary key with only 1 row in the table. And it will always only be 1 row!!

    C# help database question

  • Stuck trying to learn to do SubmitChanges
    N Nigel Mackay

    Found problem. Must have a Primary Key, so added another column to be the primary Key and it works.

    C# help database question

  • Stuck trying to learn to do SubmitChanges
    N Nigel Mackay

    Removed the primary key assignment. Still gives same problem. There is only one password in this app, and it is not there to discriminate between users, it is there because certain dangerous operations require a password so that only competent workers can do them!! Just think of it as a table that stores only 1 string.

    C# help database question

  • Stuck trying to learn to do SubmitChanges
    N Nigel Mackay

    The table (Password) has only 1 column (Password1) and only 1 row. It is also the PrimaryKey. I can retrieve the password:

    thePassword =
    from tt in MainMenu.db.Password
    select tt;
    try
    {
    password = thePassword.ElementAt(0).Password1;
    ...

    I am trying to change the value.

    if ((from tt in MainMenu.db.Password
    select tt).Count() > 0)
    {
    Password zz = MainMenu.db.Password.Single(); // or ElementAt(0) or ??
    zz.Password1 = newPassword;
    try
    {
    MainMenu.db.SubmitChanges();
    }
    ...

    I get the runtime error "A member defining the identity of the object cannot be changed ..."

    C# help database question

  • foreach referencing different rows
    N Nigel Mackay

    Looks much better.

    LINQ question csharp database linq

  • foreach referencing different rows
    N Nigel Mackay

    This is not necessarily a LINQ question, but maybe the better solution is LINQ specific. theWork is the result of a LINQ query. One of the fields is Date. I need the datedifference between each row. This is the way I've done it:

    int theOffset = 0;
    foreach (var work in theWork)
    {
    if (theOffset > 0)
    {
    theGap = work.Date - theWork.ElementAt(theOffset-1).Date;
    }
    theOffset++;
    }

    Is there a better way of doing it?

    LINQ question csharp database linq

  • Cancel CellValidating error in DataGridView, so can close form while invalid entry still present
    N Nigel Mackay

    If the user has typed an invalid entry, so that CellValidating raises an error, and they then decide to abandon the edit and want to click the Cancel button, the form won't close because the eror still exists. Error needs to be cleared first. I just can't work out a way to achieve that, short of teaching the user that if they click Cancel, and the form doesn't close, press Esc so text reverts to original and then click Cancel again. Not ideal. :)

    C# help

  • DataGridView: SelectRow if EditMode=EditOnEnter
    N Nigel Mackay

    Managed it this way private void dgvOrders_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)

    {
    Validate();
    BindingContext[dsOrders, "Orders"].EndCurrentEdit();
    dgvOrders.Rows[e.RowIndex].ErrorText = "";
    }

    But going to ask another question - if CellValidating has raised an error, how do I cancel that.

    C# css question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups