Establishment of a unique Windows Form c#



  • It's unique because there's no information on such projects. I'm trying to write an app on the issue of writers in my field, where the user will be able to add/off writers and their biography. If, more specifically, the main menu will have a set of buttons with writers ' portrait on which they are posted. I've tried to do it with the help of the OBD and winForm, but can there be a way to do it or a development environment?



  • The user will be able to add/writers and their biography.

    введите сюда описание изображения

    // Microsoft (R) Roslyn C# Compiler version 1.1.0.51204
    #r "System.Windows.Forms"
    #r "System.Data"
    

    using System.Windows.Forms;
    using System.Data;
    using System.IO;
    using System.Drawing;

    DataSet Load(string path) {
    var ds = new DataSet();
    if (File.Exists(path)) ds.ReadXml(path);
    else ds.ReadXml(new StringReader(@"<data><author name='a1'>bio1</author></data>"));
    return ds;
    }

    T Create<T>(Rectangle bounds, object data, string binding) where T : TextBoxBase, new() {
    var tb = new T() { Bounds = bounds };
    tb.DataBindings.Add(new Binding("Text", data, binding) {
    DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged,
    ControlUpdateMode = ControlUpdateMode.OnPropertyChanged,
    });
    return tb;
    }


    var f = new Form() { Width=650, Height=250 };
    var ds = Load(@"c:\temp\db.xml");
    new ListBox() { Parent=f, Bounds=new Rectangle(5,0,200, 190),
    DataSource=ds, ValueMember="author.name" };
    f.Controls.AddRange(new Control[] {
    Create<TextBox>(new Rectangle(210,0,200,30), ds, "author.name"),
    Create<RichTextBox>(new Rectangle(210,35,415,150), ds, "author.author_Text")
    });
    f.Menu = new MainMenu(new[] {
    new MenuItem("add", (s,e) => { f.BindingContext[ds, "author"].AddNew(); }),
    new MenuItem("delete", (s,e) => {
    var bc = f.BindingContext[ds, "author"];
    bc.RemoveAt(bc.Position);
    }),
    });
    f.ShowDialog();
    ds.WriteXml(@"c:\temp\db.xml"); // сохранить изменения

    For the compilation of the code and the launching of the application, for example, in Visual Studio Community 2015, it is necessary to open up View - Other Windows - C# Interactivecopy the code and press it. Enter♪

    Visual Studio Community 2015 - free version, it can be downloaded https://www.microsoft.com/en-us/download/details.aspx?id=48146 ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2