|
Thanks, I think I will try this, also thanks for the help christian but that link doesn't work.
Thanks all.
|
|
|
|
|
Ok, I don't know what to do now. I am creating a TextEditor (because I saw it in another post ).
Anyway, I have created the main form, but when the program starts it displays another form called newDlg.cs It has buttons on, with labels saying "Create a Text File:" or "Create a CSV File:" etc.
When the button is clicked, it opens the main form and assigns a variable called fileFormat to 1 or 2 (for Text File and CSV respectively). The fileFormat variable is then used to determine whether the file can be saved as a .txt or a .csv when the user clicks Save.
I need to somehow make fileFormat global because it is used in newDlg.cs and Main.cs
I tried the method of creating a globalVars.cs class but that didn't work.
Anyone got any idea?
Thanks.
|
|
|
|
|
Hello,
I am very new to the usage of C#, The task for me to perform is to convert a "string" to a list of objects. I would receive a string message, read the message and split it accordingly into list of file objects as shown below.
XXX OK|<error string=""> CRLF
[IPv4Addr:< IPv4 dotted IP address> CRLF
Port:<port number=""> CRLF
Uplink BW: <bandwidth in="" kbps=""> CRLF
File: <file name=""> CRLF]*
EOM: CRLF
It would be great, if anyone could help me on this.
Thanks,
Kishore
|
|
|
|
|
You can use the split method to turn it into an array of strongs ( using a space as a delimiter, from the look of it ). What you do to parse the strings after that depends on what you need.
|
|
|
|
|
Hi Kristamed, you can use the Regular Expressions, these have more powerful.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
The following code creates a string object with substrings separated with '|' character. In order to get an array of strings you could use string.Split method:
<br />
string str = "test1|test2|test3";<br />
string[] list = str.Split('|');<br />
|
|
|
|
|
hi
i want to invisible first row of my DataGridView,But The following error shown me :
Row associated with the currency manager's position cannot be made invisible.
my code is :
this.categoryTableAdapter.Fill(this.dataSet_AddressBook.Category);
categoryDataGridView.DataSource = this.categoryBindingSource;
categoryDataGridView.Rows[0].Visible = false; // Error Occured in this line
How to solve my problem and set categoryDataGridView.Rows[0].Visible to false ?
thanks
|
|
|
|
|
If you don't want to see it, why don't you remove it ?
|
|
|
|
|
hi
i want to use this row in other forms,but in the one form i want to set it's Visible to Flase.
|
|
|
|
|
OK, so make a copy of your data source, remove the row, and set that as the data source in this instance. Or handle the event that's fired when a row is rendered, and stop it from rendering the first row.
|
|
|
|
|
hi
can u explain more ?? if u can please give me an example .. thanks ..
|
|
|
|
|
If you use the Clone method to copy the data source, you can remove the top row from the copy.
|
|
|
|
|
Hi hdv212.
You can use the row filter property from DataView.
Example:
DataTable dt = new DataTable();<br />
this.categoryTableAdapter.Fill(dt);<br />
dt.DefaultView.RowFilter = "category_id <> 1";
categoryDataGridView.DataSource = dt
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
I currently have a dual monitor setup on my system, one a monitor, and one a TV. the problem is, my TV is not always on, or someone is using it, therefore I am left with only one Monitor on a dual monitor setup. I could activate and deactive my setup, but that is bothersome. What I wanted to do is create a program that will allow me to move existing windows to specific locations. For example, if a window is stuck on my TV monitor, I can input the coordinates of my computer monitor, and the window will be moved. I have been trying to target the processes, but I don't seem to be able to set the location of the window. Does anyone have any ideas?
|
|
|
|
|
i dont know how to do it in c# but you can do it using hardware profile settings
It is Good to be Important but!
it is more Important to be Good
[My Question]
|
|
|
|
|
Hi Amar Chaudhary.
You can do it, using InteropServices.
Example:
First you need attach the follow namespace
using System.Runtime.InteropServices;
Second you need import the Microsoft Windows Runtime dll's for declare the extern methods.
[DllImportAttribute("user32.dll")]<br />
public static extern bool ReleaseCapture();<br />
<br />
[DllImportAttribute("user32.dll")]<br />
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
Third you need declare the follow constants and methods for invoke the functions
private const int WM_NCLBUTTONDOWN = 0xA1;<br />
private const int HTCAPTION = 0x2;<br />
<br />
private void MoveForm()<br />
{<br />
ReleaseCapture();<br />
SendMessage(this.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);<br />
}<br />
<br />
protected override void WndProc(ref Message m)<br />
{<br />
base.WndProc(ref m);<br />
<br />
int WM_NCHITTEST = 0x84;<br />
if (m.Msg == WM_NCHITTEST)<br />
{<br />
int HTCLIENT = 1;<br />
int HTCAPTION = 2;<br />
if (m.Result.ToInt32() == HTCLIENT)<br />
{<br />
m.Result = (IntPtr)HTCAPTION;<br />
}<br />
}<br />
}
Finally you need call the function with any MouseDown event
private void button1_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
if (e.Button == MouseButtons.Left)<br />
{<br />
this.MoveForm();<br />
}<br />
}
Remember that you can replace the "this.Handle" for you Window Handle that you want move.
I hope that this resolve your problem.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
That's great. Thanks for the info.
|
|
|
|
|
you got my 5
It is Good to be Important but!
it is more Important to be Good
[My Question]
|
|
|
|
|
hey shopi30,
I tried using the code, but could not get it working. I can move "my" form by using this.Handle, but if I target another handle, like iexplore, I get nothing. I have tried getting the process handle by process.Handle, and also process.MainHandle, but no luck. Do I have to set focus to the process that I want to move? If so, how do I do that? Also, is there any way that I can specify the x and y co-ordinates of the window, or is it all based on the cursor?
|
|
|
|
|
Hi Now_Loading.
Try using:
[DllImportAttribute("user32.dll")]<br />
private extern static IntPtr GetForegroundWindow();
And change "this.Handle" to "GetForegroundWindow()"
GetForegroundWindow method return the Handle from the current window active.
If this don't solve your problem tell me and I'll be sending you other options.
By the way if you can help me with these System.Data.OleDb & Microsoft Excel I'll be thankful with you.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
I have one form.
On the form I have many different controls: panels, buttons, datagridviews and others...
How can I do to do when I Click on controls, I have a Message with Control Name?
|
|
|
|
|
In your click-Handler there's a parameter called sender . You can cast it and the get the name of the control.
Like that:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(((Button)sender).Name);
}
Make sure to do a proper cast if you use a general click handler for all controls.
E.g.
if(sender is Button) { (Button)... }
if(sender is Label) { (Label)... }
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
No, I don't want make click handler for all Controls,
I want use for this for example IMessageFilter
public DataForm()
{
InitializeComponent();
MyMessageFilter MessageFilter = new MyMessageFilter();
Application.AddMessageFilter(MessageFilter);
}
class MyMessageFilter : IMessageFilter
{
const int WM_LBUTTONCLICK = 0x0201;
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_LBUTTONCLICK)
{
???
???
???
}
return false;
}
}
|
|
|
|
|
I haven't used a MessageFilter yet, but the Message struct contains a property named hwnd . You can use Control.FromHandle(m.hwnd) to get the control associated with this message.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have not understood, you could not give an example?
|
|
|
|