|
I find it unsightly that datgridview only paints the
amount of rows needed for records returned.
ie: only 2 records returned to datagridview means only 2 formated rows painted.
Is there a way to fill the datagridview with "empty" but formatted rows. Or at least make it appear to?
Thanks for helping with my ocd
|
|
|
|
|
add desired number of empty rows in your data table
|
|
|
|
|
|
Scenerio:
I have 2 forms. Open form2 from toolbarButton on form1.
No problem.
Close form2.
Try to open form2 a second time from same toolbarButton and it doesnt work anymore.
Thanks in advance
Yes I already know I'm a bonehead
|
|
|
|
|
If you could post your code for the "open button" on form 1 and also the code for the "close button" on form 2, it might help.
I'm guessing the problem lies in your close code for form 2.
Glen Harvy
|
|
|
|
|
I think you may be right, I am just hitting the red X in the top right corner of the form.(next to minimize/maximize)
What should I add to properly close the form?
Thanks again
|
|
|
|
|
this.Close();
but where to handle the red X at top right ?
|
|
|
|
|
if you are not openning your form as dialog box, object of form gets dipose after closing .so next time if you want to open it you have to create an new object.
|
|
|
|
|
The close is being called OK then - show us the code that you are opening it with. For example:
private void openForm2Button_Click(object sender, EventArgs e)<br />
{<br />
Form frmNew = new Form2();<br />
frmNew.ShowDialog();<br />
}
Glen Harvy
|
|
|
|
|
private void tbtnTesting_Click(object sender, EventArgs e)
{
try
{
ShowForm(ShowFormEnum.Testing);
}
catch (Exception ex)
{
OnRaiseError(this, new ErrorEventArg(ex));
}
}
|
|
|
|
|
It's far to complicated for me to follow although I have a rough idea - perhaps someone else can see what you are trying to achieve.
Start with the simple solution:
private void tbtnTesting_Click(object sender, EventArgs e)
{
try
{
Form frmNew = new Testing();
frmNew.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show("Can't open form " +ex);
}
}
and then enhance the code with your ShowFormEnum etc. That way you can find your problem in a step-by-step methodology.
Glen Harvy
|
|
|
|
|
Hello,
Is there a way, to hide the listview items instead of removing them.
I need to filter the listview items depending upon the content of lets say, a combo box.
Currently, i have to clear the listview, reload it and then filter it by removing the items which do not match the content of the combo box.
the clearing and the reloading back consumes a lot of time. Hence, it would be great if i could simply hide the items in a listview.
Alternatively, it is ok, if I use any other control similar to a listview, which allows me to hide certain items rather than removing them.
keshav kamat
systems engineer
India.
|
|
|
|
|
You could have the user make their selection in the combobox and then fill the listview by first filling the relative datatable with only those rows that match your filter.
If you don't mind "blank" rows in the listview you could just do a foreach and make the fore and back colours black or pink or whatever
Glen Harvy
|
|
|
|
|
The problem is that the "blank" items would still be selectable. Also, the "blank" items could be anywhere in the list (not just the end) making the control look really strange. It would work well until a user got a hold of it and started selecting "blank" items...
Ian
|
|
|
|
|
|
hey Glen.
Thanks for the reply.
I will try the same. However, it would look ugly to have empty rows when one is filtering. Still worth a shot.
Alternatively, I am trying the same with a data grid as well.
keshav
|
|
|
|
|
Instead of managing the listbox's items directly, you can databind the listbox to a list[string]. You can maintain a Dictionary[string, list[string]] that keeps track of all the views you want to show, then bind the listbox to the corresponding list<string>. Like this:
namespace ListBoxTest
{
public partial class ListBoxDataBinding : Form
{
Dictionary[string, List[string]] myLists = new Dictionary[string, List[string]]();
public ListBoxDataBinding()
{
InitializeComponent();
// Create a list of colors and add it to the dictionary
List[string] colors = new List[string]();
colors.Add("red");
colors.Add("green");
colors.Add("blue");
myLists.Add("colors", colors);
// Create a list of flavors and add it to the dictionary
List[string] flavors = new List[string]();
flavors.Add("vanilla");
flavors.Add("chocolate");
flavors.Add("strawberry");
myLists.Add("flavors", flavors);
}
// The user clicked the button that will cause the listbox to show flavors
private void btnFlavors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of flavors
this.filteredListBox.DataSource = this.myLists["flavors"];
}
// The user clicked the button that will cause the listbox to show colors
private void btnColors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of colors
this.filteredListBox.DataSource = this.myLists["colors"];
}
}
}
Just an idea.
BTW, when using the generic List and Dictionary types, you'll need to replace the '[' and ']' with '<' and '>'. Anyone know how to escape the '<>' characters?
Ian
|
|
|
|
|
Hey thanks Ian,
I really appreciate it man.
Keshav
|
|
|
|
|
Hi,
Sorry for my ignorance...
I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format?
A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]);
B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"];
Ron
|
|
|
|
|
(a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time.
object labelWidth = myDataTable.Rows[0]["LabelWidth"];
Never apologise for your ignorance - we all have it
Glen Harvy
|
|
|
|
|
|
Hi,
In a game I'm writing, I have 2 main meshes: Landscape and house. The landscape is where the player walks and the house is where he lives. The house is every detailed with stairs, doors and all other stuff.
Problem:
My problem is that the character simple walks through the walls and doors and I cannot climb the stair.
Can someone please help me with the code on collision detection so that I will not walk through walls, the logic for opening the door and how to implement the climbing of stairs
I'm using Artificial Engine but it has exposed the directx classes for any help in direct x will be very helpful.
Thank you
|
|
|
|
|
Hy,
Error mesaj: Object cannot be cast from DBNull to other types
Localhost everything works fine, but when i pput my works online, when i try to add a user i take this mesaj of error here: Object cannot be cast from DBNull to other types
Thanks
|
|
|
|
|
What is the relevant code at the point of failure?
|
|
|
|
|
As a guess, your "online" datatable is empty.
Glen Harvy
|
|
|
|