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
P

picasso2

@picasso2
About
Posts
147
Topics
109
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • display only first 10 files from each directory
    P picasso2

    I have this code

    public static void Main(string[] args)
    {

            var dir = @"C:\\temp\\TestDir";
            PrintDirectoryTree(dir, 2, new string\[\] { "folder3" });
        }
    
    
        public static void PrintDirectoryTree(string directory, int lvl, string\[\] excludedFolders = null, string lvlSeperator = "")
        {
            excludedFolders = excludedFolders ?? new string\[0\];
    
            foreach (string f in Directory.GetFiles(directory))
            {
               
                  Console.WriteLine(lvlSeperator + Path.GetFileName(f));
               
            }
    
            foreach (string d in Directory.GetDirectories(directory))
            {
                Console.WriteLine(lvlSeperator + "-" + Path.GetFileName(d));
    
                if (lvl > 0 && Array.IndexOf(excludedFolders, Path.GetFileName(d)) < 0)
                {
                    PrintDirectoryTree(d, lvl - 1, excludedFolders, lvlSeperator + "  ");
                }
            }
        }
    

    How can I display just the first 10 files in all directories found

    C# question data-structures

  • WinForm launching a console application
    P picasso2

    I have a C# console application that is launched from a WinForm application.
    The output of the console application is well-formatted; however, user can run the console application directly. Is there a way to restrict/force the console application to be only run from the main application (WinForm)?

    C# csharp question

  • foreach loop behavior C#
    P picasso2

    Hello experts
    I have this behavior that I cannot figure it out. The following code loops through and extracts some firewall settings. It is triggered by a button

    try
    {

    Type typeFWPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
    INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(typeFWPolicy2);

    foreach (INetFwRule rule in fwPolicy2.Rules)
    {
    lvItems.RuleName = rule.Name; ;
    lvItems.RemoteAddress = rule.RemoteAddresses;
    lvItems.Protocol = rule.Protocol.ToString();
    lvItems.LocalPort = rule.LocalPorts;
    dataGrid1.Items.Add(lvItems);
    //MessageBox.Show("close me");
    }

    }
    catch (Exception ex)
    {

    MessageBox.Show("something went wrong");

    }
    When I run it, the datagrid is populated with the same record (only the first) entry that is repeated several times.
    then I added a MessageBox to troubleshoot, then Datagrid is populated correctly but I need to acknowledge each Messagebox !!!!. It is like it just needs that extra mouse click.
    any help is greatly appreciated

    C# help csharp

  • Image on Windowsform ListBox
    P picasso2

    Can anyone help me understand this. not too much luck finding anything in google? using the following code to display a image in a button works fine button1.Image = global::AppInfo.Properties.Resources.MyImage; But if I trying to display the image on a windows Form listbox, it does not work listBox3.Items.Add(global::AppInfo.Properties.Resources.MyImage); This only displays "System.Drawing.Bitmap" text many thanks in advanced

    C# graphics help question

  • redirect URL ouput to listbox
    P picasso2

    Is there a way to re-direct the output of a ?wsdl to a listbox? for example, I'd like to add a button that invokes the following: http://serverName:port/service.svc?wsdl and send the output to a listbox many thanX

    C# wcf tutorial question

  • Registries in Windows 10 Pro
    P picasso2

    I have a basic WindowsForm C# application that loops thru a key (Dependencies) and list all values of all subkeys found. It is compiled to use Any CPU (unselecting "Prefer 32-bit" option as well ) registry hive looks like this: Dependencies -{{050d4fc8-5d48-4b8f-8972-47c82c46020f} ..... ..... -{030d4fc8-5d48-4b8f-8342-47c82c46020f} ... ... -Microsoft.VS.VC_RuntimeAdditionalVSU_x86,v11 -Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v12 .... .... When I run the application in server 2012 or higher, the application reads all values found in each subkey (works great) but when I ran it in Windows 10 Pro, only the subkeys that start with Microsoft.VS.VC_..etc are read. Any ideas how to fix it?

    C# csharp visual-studio sysadmin windows-admin help

  • replacing an image
    P picasso2

    Silverlight/C# project, I added an image object with a default image, the following code was created
    <Image Height="403" HorizontalAlignment="Left" Margin="1212,86,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="360" Source="/reposMTX;component/Images/09.JPG" />

    How can I change the image when a button is clicked?
    I tried this

    image1.Source = new BitmapImage(new Uri("http://tpsa11/images/shi.bmp", UriKind.RelativeOrAbsolute));

    but does not seem to work

    WPF question csharp

  • two comboBoxs
    P picasso2

    Yes, I should have done fist. Thank you public Home() { InitializeComponent(); //initilize the combobox comboBox1.Items.Add("CAR"); comboBox1.Items.Add("PLANE"); comboBox1.Items.Add("MOTORCYCLE"); for CB1 private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { string selec = comboBox1.SelectedItem.ToString(); switch (selec) { case "CAR": { comboBox2.Items.Clear(); label3.Content = "Select cars"; comboBox2.Items.Add("Model"); comboBox2.Items.Add("Color"); } break; case "PLANE": { comboBox2.Items.Clear(); label3.Content = "Select Site"; comboBox2.Items.Add("model"); comboBox2.Items.Add("EngineType"); comboBox2.Items.Add("choice 1"); comboBox2.Items.Add("choice 2"); } break; }//end of switch } FOR CB2 private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e) { EclipseMTXDomainContext context1 = new EclipseMTXDomainContext(); //load datagrid from database string selec = comboBox2.SelectedItem.ToString(); switch (selec) { case "model": { //GET ALL MOdels dataGrid1.ItemsSource = context1.Protons; context1.Load(context1.GetProtonsFilteredQuery(1)); } break; case "EngineType": { //GET ALL Engine Types dataGrid1.ItemsSource = context1.Protons; context1.Load(context1.GetProtonsFilteredQuery(1)); } break; }//end of switch }

    C# csharp help

  • two comboBoxs
    P picasso2

    I have a C# and Silverlight project with two combo boxes (CB1, CB2)
    -CB1 is initialized and populated with few items.
    (e.g. car, plane, motorcycle)
    -User selects an item (e.g. car) and CB2 gets automatically populated
    (e.g. model, year, color) via the cb1_SelectionChanged()
    -user selects the item from CB2 (e.g. model) and a datagid is populated accordingly.

    Problem:
    Once I selected item from CB2 and datagrid is populated correctly, attempting to select a different item from CB1 generates a “Object reference not set to an instance of an object”
    To go around just select a different item then back again to the item and that woks but is really annoying. :)
    Any ideas will be greatly appreciated

    C# csharp help

  • DomainServices adn [RequiresRoles()]
    P picasso2

    I thinks so,…It is a silverlight application that uses domainservies and RIA!!!! In any case, it is always nicer to refrain making comments if there is no benefit to it. There are always nicer users willing to help.

    WPF asp-net database security debugging question

  • DomainServices adn [RequiresRoles()]
    P picasso2

    I am using a [RequiresRole("MANAGERS")] in my domainServices to restrict the use of a RIA services. Users are configured via the ASPNET Web administrative tool.

    When publish the website, the authentication does not work. I can verify that access to the DB and all files work fine by just removing the [RequiresRole("MANAGERS")] statement

    However, If I run the project in debug mode (VS2010) then it works as expected.

    May be I am missing something in the web.config. Any other files I need to copy from my project to the website? Any ideas are greatly appreciated.

    WPF asp-net database security debugging question

  • get two columns
    P picasso2

    I have a SL/WPF application that populates a datagrid. The button contains this code:

    MyDomainContext context = new MyDomainContext();
    dataGrid1.ItemsSource = context.DBTables;
    context.Load(context.GetTwoDataBasesQuery());

    The DomainServices.cs contains:

    public IQueryable<DBTable>GetTwoDataBases()
    {
    return this.ObjectContext.DBTables;
    }
    This code works fine but returns all columns in the context
    I need to return only two columns so changed is as follows

    public IQueryable<DBTable>GetTwoDataBases()
    {

            return GetDBTables().Select(m => new { m.col1, m.col2 });
            
        }
    

    But code has errors, does not accept the “return” .
    how do I get col1 and col2?
    Many thanX

    WPF question csharp wpf linq

  • query using Lamda expression
    P picasso2

    ThanX Matt, that is not the issue, it is just careless type when creating the post.

    WPF database csharp css linq help

  • query using Lamda expression
    P picasso2

    Hello Listeners, I created a SL application (using C#) that returns contents of a table in SQL database. Table has 5 columns (FirstName, LastName, Age..etc). --A grid is populated with following: EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesQuery()); --Mine domain service has an entry as follows: public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } This works fine but What I am trying to do now is load only two columns at a time so I added this in the domain services public IQueryable GetTwoColms(string db1,string db2) { return this.ObjectContext.DBTables.Where(P => P.col1Name == cl1 && P.col2Name == cl2); } --And the main program, added this to a button action EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context. GetTwoColms Query("LastNames","FirstName")); It does not fail but it does not return anything either. Any help is greatly appreciated

    WPF database csharp css linq help

  • change color of Datagrid text
    P picasso2

    Hello members, I have tables (DBTable) in SQL 2008 that contains two columns that look like this: Col1 Col2 0 1 0 1 1 1 1 1 0 1 I created a Silverlight application (BI -RIA and domain services) that populates the datagrid as follows MyCarsDomainContext context = new MyCarsDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesCompareQuery()); I would like to change the row background color (just the text color will work fine too) based on the value of Col1. If 0 then row is red, if 1 then row is blue Any help is greatly appreciated

    WPF database help

  • Silverlight business application
    P picasso2

    How can I run a store procedure (SQL 2008) from domain services? default method is to simple public IQueryable GetCars() { return this.ObjectContext.Cars; } It does not have to be a SP, I just thought it may be cleaner, basically what I need to run is something like this: Select col1 from DBTables where ltrim(rtrim(col1)) not in (select ltrim(rtrim(col2)) from DBTables where col2 is not null) order by 1 Select col2 from DBTables where ltrim(rtrim(col2)) not in (select ltrim(rtrim(col1)) from DBTables where col1 is not null) order by 1 any help is greatly appreciated

    WPF question sharepoint database linq business

  • Business Application in VS2010
    P picasso2

    Hello forum, (sorry if duplicate, I might have post this but cannot find it) Just created a SL Busines application. In the MYDomainService.cs the default queries are generated. public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } The default returns all columns in the specified table. I would like to run a script like this: SELECT * From DBTables A FULL OUTER JOIN Information_Schema.Columns B ON A.Column_Name = B.Column_Name AND B.Table_Name = 'FY2007_DATA' AND B.Table_Schema = 'dbo' WHERE A.Table_Schema = 'dbo' AND A.Table_Name = 'FY2006_DATA' AND (A.Column_Name IS NULL OR B.Column_Name IS NULL) Any help will be greatly appreciated

    C# linq business tools help

  • Business Application Silverlight
    P picasso2

    Hello forum, (sorry if duplicate, I might have post this but cannot find it) Just created a SL Busines application. In the MYDomainService.cs the default queries are generated. public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } The default returns all columns in the specified table. I would like to run a script like this: SELECT * From DBTables A FULL OUTER JOIN Information_Schema.Columns B ON A.Column_Name = B.Column_Name AND B.Table_Name = 'FY2007_DATA' AND B.Table_Schema = 'dbo' WHERE A.Table_Schema = 'dbo' AND A.Table_Name = 'FY2006_DATA' AND (A.Column_Name IS NULL OR B.Column_Name IS NULL) Any help will be greatly appreciated

    WPF linq business tools help

  • Silverlight-Running SQL scripts
    P picasso2

    Hello forum, I’ve created a Silverlight application that includes a ADO Entity data model and DomainService class. In the main page the context is created MyDomainContext context = new MyDomainContext(); dataGrid1.ItemsSource = dp1; context.Load(context.GetDBTablesQuery()); The default configuration (in MyDomainServices.cs)works fine. For example, the following code populates a datagrid. public IQueryable GetDBTables() { return this.ObjectContext.DBTables; } My question is: How do I run a simple script (e.g. Select col1, col2 from DBTable where col1='12') Many thanks in advance

    WPF question database linq tools tutorial

  • New Table to an existing Silverlight project
    P picasso2

    I have created a SilverLight application that uses ADO and DomainServices to populate a DataGrid from an SQL 2008 database server. The context looks like this EcDomainContext context1 = new EcDomainContext(); A few months later, I added a table to the database so in order to use this new table, I had to rebuild as follows: -deleted all MyDomainServices (.cs) files -deleted the Mymodel (.edmx) file -recreate by adding the ADO and Domainservices again -reconfigure the MyDomainServices.cs as before. Well, I just added another table and I would like to know if there is an easier way to do this? Many thanks. Ps

    WPF database sysadmin 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