|
Yes, but i would like to know how to make it read from a .txt file called Title_form and change the forms title with that .txt
|
|
|
|
|
if you mean that you want to make your form title as your text file name???
|
|
|
|
|
No i want the program to read from a .txt called Title_form.txt and then inside that .txt i have the form name.
|
|
|
|
|
TextReader tr = new StreamReader(C\\test.txt);
//How many lines should be loaded?
int NumberOfLines = 15;
//Make our array for each line
string[] ListLines = new string[NumberOfLines];
//Read the number of lines and put them in the array
for (int i = 1; i < NumberOfLines; i++)
{
ListLines[i] = tr.ReadLine();
}
if the title is in number 5 line
this.text = ListLines[5];
one all the lines are added in the array then you can pick your desired one.
hope this will help you..
|
|
|
|
|
it says im missing a Assembly reference are there any imports for this method?
|
|
|
|
|
using System.IO;
Try that one.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
Stephen Hawking
|
|
|
|
|
include using system.io.stream
|
|
|
|
|
Thank you so much all it works!
|
|
|
|
|
Sure you can just use the refactoring in the IDE
|
|
|
|
|
I am using Prism to handle IoC, I can do this in VB.NET:
Dim _regionManager As IRegion
Dim _container As IUnityContainer
...
Dim mainRegion As IRegion = _regionManager.Regions(RegionNames.MainRegion)
For Each v As View In mainRegion.Views
mainRegion.Remove(v)
Next
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, GetType(MaterialView)
I am getting the following eror: non-invocable member ....Regions cannot be used as a method.
When I use this C# conversion:
IRegion mainRegion = _regionManager.Regions(RegionNames.MainRegion);
for each(var v in mainRegion.Views)
{
mainRegion.Remove(v);
}
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, typeof(MaterialView));
Some hints as to why would be very helpfull.
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
Regions is a collection. You access this using the indexer operator [..] , so that would be _regionManager.Regions[RegionNames.MainRegion];
|
|
|
|
|
Hi Pete, thanks for the help. I should have remembered this as I had the same issue a few days ago accessing the fields in a Datarow!
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
I'm looking for information on networking.
I've been searching for a while now, but the best I was able to do was send bytes of data through my network using a very simple Server program/client program TCP setup in Microsoft Visual Studios 10. I gave the Server an IPAddress and told the client to connect to that specific address.
My end goal is learning how to create a simple multiplayer game using XNA Windows Game.
Any help, information, or direction is greatly appreciated!
|
|
|
|
|
clonze wrote: send bytes of data through my network using a very simple Server program/client program TCP
You'd use a socket, similar to this[^] example
|
|
|
|
|
yes, i was able to use the socket to send bytes over my network; however, i'm completely lost when it comes to sending bytes over the internet! I've found that link before, but I didn't think it was what I was looking for. I'll look more into it now though, thanks.
|
|
|
|
|
I'd work in a similar fashion; you connect to a public IP, and do your thing. The only annoying part being the firewalls and routers in between - some ports are closed by default.
|
|
|
|
|
In VB.NET I do this:
Public Property LogoutCommand As ICommand
...
LogoutCommand = New RelayCommand(AddressOf LogoutExecute, AddressOf CanLogoutExecute)
but when I try this in C#:
public ICommand LogoutCommand;
...
LogoutCommand = new RelayCommand(LogoutExecute, CanLogoutExecute);
...
private void LogoutExecute(){...}
private bool CanLogoutExecute()
{
return true;
}
...
I get an error: "the best overloaded method match for RelayCommand(System.Action<object>, System.Predicate<object>) has some invalid arguments"
Here is the RelayCommand Class:
public class RelayCommand : ICommand
{
private readonly Action<Object> _execute;
private readonly Predicate<Object> _canExecute;
public RelayCommand(Action<object> execute): this(execute, null){ }
public RelayCommand(Action<object> execute, Predicate<Object> canExecute)
{
if (execute == null)
{
throw new ArgumentException("execute");
}
_execute = execute;
_canExecute = canExecute;
}
[DebuggerStepThrough()]
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
_execute(parameter);
}
}
public class RelayCommand<T> : ICommand
{
private readonly Action<T> _execute;
private readonly Predicate<T> _canExecute;
public RelayCommand(Action<T> execute): this(execute, null){}
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
{
if (execute == null)
{
throw new ArgumentException("execute");
}
}
[DebuggerStepThrough()]
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute((T)parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
_execute((T) parameter);
}
}
Any suggestions?
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
modified 18-Nov-12 3:54am.
|
|
|
|
|
Andy_L_J wrote: AddressOf
... in your VB declarations is one clue here along with your error message.
Your RelayCommand constructor takes two delegates. In VB.Net you use the AddressOf operator to get a delegate for a method. In C# we use a delegate directly.
Try something like this to create delegates to your methods:
LogoutCommand = new RelayCommand(new Action<object>(LogoutExecute), new Predicate<object>(CanLogoutExecute));
Edit: Your LogoutExecute and CanLogoutExecute methods should both have one parameter of type object .
modified 18-Nov-12 4:32am.
|
|
|
|
|
Cheers Dave, worked a treat.
I am self-learning C# after many years with VB.NET and some of conversions are making me crazy.
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
Keep persevering! Most things are fairly straight forward in my experience - I was once a VBer too, many years ago. Now I actually find it quite difficult to code in VB for the first 15 minutes or so, mainly cause I want to put a ; at the end of everything and wrap things in { }
|
|
|
|
|
I am enjoying the process however at the moment I get a couple hunderd moans from the compiler about missing ; and { } every time I build
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
Hi all,
I'm not sure this is the right forum,but I thought I'll give it a try,since not getting answers from DevExpress support center.
I'm using DevExpress GridView for winforms applications.
Also using VS2010 and Linq to SQL.
My grid view is binded to a LINQ table which represent a table in my database.
Let say I have a Person class with two properties - FirstName and LastName.
These two properties are persistent.
What I'm trying to do is to add a third property which will not be persistent and called FullName = LastName + FirstName.
This is working fine and the grid display the full name correctly.
My problem is when trying to filter values using the filter buttons in the column header,the dropdown list is empty...
When making FullName saved in the database - everything is OK.
Can anyone save me?
Thanks,
Eli
|
|
|
|
|
Can you override some kind of grid_OnFilter event?
There would be just added filter for both FirstName and LastName. But really whole idea for that grid is wrong. Why? What happend whe you will have 1000, 10000, or 1000000 records? Grid will fetch all of them filter, sort and then show. More records then more time this will take.
No more Mister Nice Guy... >: |
|
|
|
|
|
using (FileStream fs = File.OpenRead(path))
{
fs.BeginRead();
}
|
|
|
|
|
A few points;
- "Help" is a too generic subject; they're all looking for help
- The question is hard to find; ask a question, explain what you tried, and why it didn't work
- Reading a
Stream is often-described pattern[^]. Do you really need the async version? Wouldn't ReadToEnd[^] be a bit simpeler?
Did you write/use an async method before?
|
|
|
|