|
Hello,
How can I check if there is a remainder in the division operation?
Thank you.
|
|
|
|
|
With the modulo operator: %
---
b { font-weight: normal; }
|
|
|
|
|
To write to Notepad from c# without creating a file I found the following code.
I need this because I dont have write permission on the client but I need to show
the extracted data in the Notepad.
Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Private Const WM_SETTEXT As Integer = &HC
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - Notepad") '/// assuming you have notepad open.
Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString)
Dim strText As String = "some text"
If Not x = 0 Then
SendMessage(x, WM_SETTEXT, 256, strText)
End If
End Sub
My question is: Is there a way to append text to notepad instead of WM_SETTEXT. I need this because sometimes the data to be extracted is huge and WM_SETTEXT may not suffice.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello!
I have an two-dimensional string array with values looking like this:
0 1
----
1 b
0 c
1 x
2 v
1 f
0 k
and so on. now I want to sort this array on the first column, so it would look like this:
0 1
----
0 c
0 k
1 b
1 x
1 f
2 v
I suppose I will have to do some manual sorting since I cant seem to find a sorting method for the array control.The only solution Ive come up with so far is making another array, looping through the first array and adding the row if column[0] = current value, but this solution would force me to loop for every new value in the column, which isnt very efficient.
Can anyone help me come up with a better solution?
/regards Magnus
|
|
|
|
|
there is a static Sort method on the Array class
|
|
|
|
|
Array class have Sort method but it sort one dimention array to make Array class sort two dimention array
you have to implement IComparer interface (Compare method)
and pass the implementation to Sort method
Sort Method[^]
|
|
|
|
|
hmm I think I wasnt very clear in my post. The array, or vector or whatever its called I have looks like this:
string [,] arAmount;<br />
<br />
arAmount= new string [coll.Count, 2];
and since I can't find the sort method u guys spoke of I guess it's not an actual array, but called something else.
|
|
|
|
|
Please modify the code code to handle 2D array.
public String[] GrowArray(String[] pOldArray, Int32 pNewSize)
{
Int32 counter = 0;
String[] newArray = null;
if(pOldArray != null)
{
if(pNewSize <= pOldArray.Length)
{
newArray = pOldArray;
}
else
{
newArray = new String[pNewSize];
foreach(String item in pOldArray)
{
newArray[counter] = item;
counter++;
}
}
}
//all the items of the old array have been copied to the new array and the new items are NULL
return newArray;
}
Hope this helps
Live Life King Size
Alomgir Miah
|
|
|
|
|
|
|
First,i am weak in english ,so i will try to express myself clearly!
Now ,i have some media files ,such as *.avi,*.mpg,then i want to get any frame from these files ,and save the frame as a photo
i don't know how to do, i have searched for it from the codeproject ,but i just find some examples which capture frame from a vedio deveice.But now ,i want to capture frame from a file
please help me,give me some advise or example
my email: sgc8228@163.com
|
|
|
|
|
|
|
Hi
I've been using XMLTextReader to be able to edit elements within an XML file easily (using the lineNumber and linePosition with a simple text handler), however I'm having a problem with navigating...
The object returned by readSubTree() is not of type XMLTextReader, so I can't use that and still get the line info out of it, and there doesn't appear to be a move/readToParent function that would take me back up a level in the XML. I could use readFollowing to move to the next element on the Parent's level but that seems like a bit of a bodge.
Can someone tell me if/how I can read back to the parent element?
Basically I want to be able to find the line info for a couple of child elements of a particular group of elements (if that makes any sense whatsoever )
|
|
|
|
|
XmlTextReader is forward only reader. You cannot read the values already read.
So what you can do is use a variable to store the parent.
Here is an example. I have not modified the code(just copy/paste)
while (xmlTextReader.Read())
{
switch (xmlTextReader.NodeType)
{
case XmlNodeType.Element:
string elementName = xmlTextReader.Name;
EntityBase entityBase = EntityHelper.CreateEntity(elementName);
while (xmlTextReader.MoveToNextAttribute())
{
if ( xmlTextReader.Name == "ID" )
{
entityBase.ValueList["ID"] = xmlTextReader.Value;
}
else if ( xmlTextReader.Name == "Name" )
{
TreeNode tempTreeNode = new TreeNode( xmlTextReader.Value.Trim());
entityBase.ValueList["Name"] = xmlTextReader.Value;
tempTreeNode.ImageIndex = ENTITYIMAGE;
if ( currentTreeNode == null )
{
tempTreeNode.Tag = entityBase;
currentTreeNode = tempTreeNode;
this.Nodes.Add(tempTreeNode);
}
else
{
tempTreeNode.Tag = entityBase;
currentTreeNode.Nodes.Add(tempTreeNode);
currentTreeNode = tempTreeNode;
}
//
//Add the dummy node
//
this.dummyNode = new TreeNode("dummy");
tempTreeNode.Nodes.Add(this.dummyNode);
break;
}
else
{
entityBase.ValueList[xmlTextReader.Name] = xmlTextReader.Value;
}
}
break;
case XmlNodeType.Text:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.CDATA:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.ProcessingInstruction:
Console.Write("");
break;
case XmlNodeType.Comment:
Console.Write("");
break;
case XmlNodeType.Document:
Console.Write("");
break;
case XmlNodeType.Whitespace:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.SignificantWhitespace:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.EndElement:
if ( currentTreeNode != null )
{
if ( currentTreeNode.Parent == null )
{
currentTreeNode = null;
}
else
{
currentTreeNode = currentTreeNode.Parent;
}
}
break;
}
}
xmlTextReader.Close();
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello, I bind datas in the datagrid from the database in that grid 3 columns. 1. Username, 2. Password and final Template column(in that column used checkbox control) and one button in the web form the button caption 'DELETE' when i press the delete button i want to delete Username and password Wheather it is checked by the Template column(checkbox column).
Pls help me to validate the template column (CheckBox column i want to check it select or not)
|
|
|
|
|
Please post this in ASP.NET forum.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Can any one help me out? I want a solution for how to zip and unzip files or folders using c#.
Thanx in advance
|
|
|
|
|
This is new in C# 2.0.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
|
Hi!
I have a datagrid with some custom DataGridComboBoxColumns. I have 3 columns that are supposed to be filled with different data according to what is chosen i the other comboboxes. It's kinda like this. 1st column is e.g. a list of box names. The 2nd column are item types inside a selected box. 3rd column contains names of the selected item type. If you have 2 items of type 'Car' in the box, the 3rd column will contain e.g. "Car 1", "Car 2".
I set the datasource for the comboboxes in a TableStyle. I need the data for each combobox to be updated dynamically and i need different values in the comboboxes for each row.
Is this even possible??
Thanks,
Atle
|
|
|
|
|
I have problem about WebBrowser.
When program open webpage http://racing.ustrotting.com/entries.cfm and click button view already.
It's not save webpage after click button view but it's save before click button.
How to do it to save after click button view ?
Best regards
public void savewebpage(AxSHDocVw.AxWebBrowser axWebBrowser1,string strfile)
{
IHTMLDocument2 doc = (IHTMLDocument2) axWebBrowser1.Document;
UCOMIPersistFile pf = (UCOMIPersistFile) doc;
pf.Save(@strfile,true);
}
public void GetMainPage(AxSHDocVw.AxWebBrowser axWebBrowser1,
ref string strfile,string htmlpath)
{
System.Object nullObject = 0;
string str = "";
System.Object nullObjStr = str;
axWebBrowser1.Navigate("http://racing.ustrotting.com/entries.cfm",
ref nullObject, ref nullObjStr,ref nullObjStr, ref nullObjStr);
while (axWebBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
Application.DoEvents();
}
switch(Task)
{
case 1:
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;
HTMLInputElement btnView =
(HTMLInputElement) myDoc.all.item("Submit", 0);
btnView.click();
Task++;
break;
case 2:
break;
}
savewebpage(axWebBrowser1,"c:\\myWeb.html");
}
Best regards
tery
|
|
|
|
|
Hi,
I have two files one containing Multiple JPEGs (one after another in single file) when i view the file in picture box, only one jpeg is shown
in another file i have size for each image, i can parse this file and get size and location of any jpeg in that file
can anyone tell me how to get jpeg stored in a file when i know its location in that file and size
Regards,
Arus
|
|
|
|
|
arusmemon wrote:
when i view the file in picture box, only one jpeg is shown
That's all the picture box does.
arusmemon wrote:
can anyone tell me how to get jpeg stored in a file when i know its location in that file and size
You can probably read the jpeg that you want and pass the stream into a constructor.
Christian Graus - Microsoft MVP - C++
|
|
|
|