|
And perhaps copy to the new array while searching for the index.
|
|
|
|
|
Use a generic list, add all of your elements, and then call the list Sort() method.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I want to set and focus to a specified node in treeview.it means I want to go to specified node in treeview
How can I do it ?
Hello Friends
|
|
|
|
|
Iterate through your treeview until you find the one you need, then set the treeviews SelectedNode property and call the selectednode's EnsureVisible method.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Simply you can find tree node within treeview using the find method as show below
string myNodeName="abc"
TreeNode[] node=new TreeNode[1];
node=treeView1.Nodes.Find(myNodeName,true);
treeView1.SelectedNode=node[0];
this is simple way how u can find your node within the treeview
Abdul Rahaman Hamidy
Senior Student Student in Computer Science
Kabul, Afghanistan
Software Developer
|
|
|
|
|
I HAVE ALREADY ANSWERED THIS. There is no reason to repost it.
Everything makes sense in someone's mind
|
|
|
|
|
I have a 512x512 image, and using lockbits and unsafe code, i visit each pixel to retrieve that pixel value. This is a grayscale image.
What i want to do is start the retrieval from the 256th pixel in each row (or, collectively, the right half of the image).
Heres what i tried:
inputImg = Image.FromFile(inputImgPath);
b = (Bitmap)inputImg;
BitmapData bmData = b.LockBits(new Rectangle(256, 0, b.Width, b.Height),
ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
byte* p = (byte*)(void*)Scan0;
int nOffset = stride - 256;
for (int y = 0; y < b.Height; ++y)
{
for (int x = 0; x < 256; ++x)
{
current = (byte)p[0];
p++;
}
p += nOffset;
}
}
b.UnlockBits(bmData);
The problem is occurs when i use the LockBits method. The compiler says the parameter is not valid.
modified on Saturday, August 23, 2008 12:33 AM
|
|
|
|
|
gigahertz205 wrote: The compiler says the parameter is not valid.
What parameters is it supposed to take? Does it take the Rectangle object?
---modified
Try using the code block button to make your code snippet easier to read.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The parameters are as follows:
public System.Drawing.Imaging.BitmapData LockBits(System.Drawing.Rectangle rect, System.Drawing.Imaging.ImageLockMode flags, System.Drawing.Imaging.PixelFormat format)
And the rectangle:
public Rectangle(int x, int y, int width, int height)
This worked when my starting point was at (0,0) and visited every single pixel in the image, but when its at (256,0), it gives me back an error.
EDIT: this is where i got the code from (http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx[^])
|
|
|
|
|
You might want to ask the author, Christian, in the said article's message board.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I am using the code below to view list of car brands below car makes but while loading i get the above error and i guess it's because the car make value is null during loading. I tried to use if (cboVehicleMake.SelectedItem == null) but still getting the same error.
what can i do?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Rent_A_Car
{
public partial class frmMain : Form
{
SqlConnection sql_connection = null;
SqlCommand sql_command = null;
SqlDataAdapter sql_adapter;
// DataTable data_table = null;
SqlDataReader sql_reader = null;
DataSet data_set = null;
public frmMain()
{
InitializeComponent();
}
private void hide_panels()
{
panelVehicles.Visible = false;
panelVehicleDetails.Visible = false;
}
private void get_vehicle_makes()
{
try
{
sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true;");
sql_connection.Open();
sql_command = new SqlCommand("sp_get_vehicle_makes", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
// Create data adapter object
sql_adapter = new SqlDataAdapter();
sql_adapter.SelectCommand = sql_command;
// Create a dataset object and fill with data using data adapter's Fill method
data_set = new DataSet();
sql_adapter.Fill(data_set, "vehicle_makes");
// Attach dataset's DefaultView to the combobox
cboVehicleMake.DataSource = data_set.Tables["vehicle_makes"].DefaultView;
cboVehicleMake.DisplayMember = "vehicle_make";
cboVehicleMake.ValueMember = "vehicle_make_id";
cboVehicleMake.SelectedValue = -1;
}
// catch (Exception oE)
// {
// MessageBox.Show("Problem Populating Reader Box: [" + oE.ToString() + "]");
// }
finally
{
if (sql_reader != null) sql_reader.Close();
// if (sql_connection != null)
// {
// if (sql_connection.State == ConnectionState.Open)
// sql_connection.Close();
// }
}
}
private void get_vehicle_brands_by_make()
{
try
{
sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true;");
sql_connection.Open();
sql_command = new SqlCommand("sp_get_vehicle_brands_by_make", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("@vehicle_make", SqlDbType.Int).Value = Convert.ToInt32(cboVehicleMake.SelectedValue);
// Create data adapter object
sql_adapter = new SqlDataAdapter();
sql_adapter.SelectCommand = sql_command;
// Create a dataset object and fill with data using data adapter's Fill method
data_set = new DataSet();
sql_adapter.Fill(data_set, "vehicle_brands");
// Attach dataset's DefaultView to the combobox
cboVehicleBrands.DataSource = data_set.Tables["vehicle_brands"].DefaultView;
cboVehicleBrands.DisplayMember = "vehicle_brand";
cboVehicleBrands.ValueMember = "vehicle_brand_id";
cboVehicleBrands.SelectedValue = -1;
}
// catch (Exception oE)
// {
// MessageBox.Show("Problem Populating Reader Box: [" + oE.ToString() + "]");
// }
finally
{
if (sql_reader != null) sql_reader.Close();
// if (sql_connection != null)
// {
// if (sql_connection.State == ConnectionState.Open)
// sql_connection.Close();
// }
}
}
private void toolExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void navNewVehicle_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
if (panelVehicleDetails.Visible != true)
{
// hide all panels;
hide_panels();
get_vehicle_makes();
// panelVehicleDetails.Width = 635;
// panelVehicleDetails.Height = 435;
// panelVehicleDetails.Top = 200;
// panelVehicleDetails.Left = 52;
panelVehicleDetails.Location = new System.Drawing.Point(navMain.Width + 5, navMain.Top);
panelVehicleDetails.Size = new Size(this.Width - navMain.Width - 40, navMain.Height);
panelVehicleDetails.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
panelVehicleDetails.Visible = true;
/*
Control control_name = panelVehicleDetails;
control_name.Name = "panelVehicleDetails";
control_name.Width = 635;
control_name.Height = 435;
control_name.Top = 200;
control_name.Left = 52;
* */
}
}
private void navOurVehicles_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
hide_panels();
}
private void cboVehicleMake_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboVehicleMake.SelectedItem == null)
{
return;
}
else
{
get_vehicle_brands_by_make();
}
}
}
}
|
|
|
|
|
1 - don't post so much code
2 - tell us what line your code crashes on
3 - use the debugger to see what object is causing the crash, and give us more info that way, too
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
the line causing the problem is this:
sql_command.Parameters.Add("@vehicle_make", SqlDbType.Int).Value = Convert.ToInt32(cboVehicleMake.SelectedValue);
i guess because during the combobox creation it's still filling the values so it will find null value in the vehicle make but i don't know why thought i am populating the vehicle makes first?!
|
|
|
|
|
i am developing a desktop windows for application but i don't want to include the sql management express with the application therefore i want some way to do my sql statement (in case of troubleshooting) and i want to that from the same application (via admin user)
so if i place a textbox to enter the sql statements how can i view the output?
|
|
|
|
|
|
what about multip statments like in sql management express i can do this:
select * from company;
select * from employee?
how about errors output?
|
|
|
|
|
Have separate panels for them or something like that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
A TabControl with a TabPage for each result set.
When I get messages I put them in a DataTable and treat them the same.
|
|
|
|
|
I second using datagridview as suggested.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have dragged a toolbar off the toolbox onto my winform. I then opened the Buttons collection and added a button.
I can't for the life of me figure out how to set the button's image.
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: I then opened the Buttons collection and added a button
Are you doing this at runtime or in the designer?
What about the DisplayStyle and Image properties
(assuming ToolStripButton class)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have figured it out. Thanks
Everything makes sense in someone's mind
modified on Friday, August 22, 2008 5:05 PM
|
|
|
|
|
Hello,
I would like to write a function in VS2008 C# that I can use in Excel2008.
I tried with this template that is available in VS2008 TeamSystem called "Excel 2007 Add-in" - when I write some code in this provided "ThisAddIn_Startup" function it works - but I would need to write my own function (e.g. something like: public int AddMe( int a, int b ) { return a+b; } ) which is accessible from within an excel cell like =AddMe(3,4).
Any help would be highly appreciated
regards, Dussel
|
|
|
|
|
I have a class that has a property that is a struct of two Int64s. Similar to the Size property which is two Int32s if that explains it better!
How can I get this to be usable in the property grid?
At the moment, as a workaround, I've made this property private and created another public property of type string and used the struct's ToString and TryParse methods in the getter and setter to alter the original property.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I figured it out
For anyone that comes across this I needed to:
1. Create a convertor class that derived from ExpandableObjectConverter
2. Override CanConvertTo
3. Override CanConvertFrom
4. Override ConvertTo
5. Override ConvertFrom
6. Apply the TypeConverterAttribute to the property
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|